Sale Date P Q 1/4/06 9 3 2/4/06 2 7 2/4/06 3 8 2/4/06 6 6 3/4/06 1 5 5/4/06 4 2 5/4/06 5 9I want to construct a select statement that will return the following:
latest_date P_lt q_lt date-1 p-1 q-1 date-rest p-rest q-rest 5/4/06 9 11 3/4/06 1 5 {} 20 24In other words, I want to get a total of products sold on the latest date, whatever that is; products sold on the date before the latest date, whatever that is; and products sold on all the other prior dates.