know this is simple but the query is evading me.
here's the deal:
i want to get the total monthly items: sum(ItemNo),
total monthy amount: sum(ItemAmt), comulative item
from certain date<?>, commulative amount from certain
date<?>. My problem is i dont know how to get the
commulative amount from january to current month.
Here's what i've got so far:
Code:SELECT pc, consum_act, contr_no,sales_code, SUM(cynoitems) As total, sum(dollamt) as dollar (select sum(a.cynoitems) as comtotal, sum(cydollamt) as comdoll from msd a inner join msd aa on a.pc =aa.pc and a.consum_act = aa.consum_act and a.contr_no =aa.contr_no and a.sales_code = aa.sales_code where a.cydate between cdate("10/01/2008") and cdate ("01/01/2009") ) FROM msd a WHERE a.cydate = cdate("01/01/2009") GROUP BY pc,consum_act,contr_no,sales_code
the subquery part is the commulative for a given date range <this is where im lost>




Reply With Quote