• I also think that rownum is high. No, salesdate is not devideby datetime. I should doing something like this

    rownumber <= datediff (day,salesdate,baseenddate) but i dont know how to implement it.