hi i wonder if someone could help with the correct syntax. I have the following sql statement
select case when DueDate = dateadd(mm,0,DueDate) then sum(Qty) else 0 end as month1, case when DueDate = dateadd(mm,-1,DueDate) then sum(Qty) else 0 end as month2
From db
RD_ITEMS
i want to sum the qty for everything where the due date is last month and the month before and so on for 12 months..
Can someone explain what im doing wrong.
Thanks in advance
select case when DueDate = dateadd(mm,0,DueDate) then sum(Qty) else 0 end as month1, case when DueDate = dateadd(mm,-1,DueDate) then sum(Qty) else 0 end as month2
From db
i want to sum the qty for everything where the due date is last month and the month before and so on for 12 months..
Can someone explain what im doing wrong.
Thanks in advance