select crsB.category, jul, [fisyear] from (select distinct category from [RTA-Revenues]) as crsA inner join ( select [fisYear], [category], CASE WHEN month([receiveddate])=7 THEN sum(AMOUNT) ELSE CAST(0 AS numeric(12,2)) END as Jul from [rta-revenues] group by receiveddate, FISYEAR, CATEGORY) as crsB on crsA.CATEGORY = crsB.CATEGORY order by FISYEARNote that sqlserver is insisting on having receiveddate in the group by clause. Something I did not have before. As above it runs but produces multiple rows for each fisyear/category combination. Something I do not want.
>iif(month(receiveddate)=7,amount,000000000000.00) >(CASE WHEN month(receiveddate)=7 THEN AMOUNT ELSE CAST(0 AS numeric(12,2) END) >>
>>select ; >> sum(iif(month(receiveddate)=7,amount,000000000000.00)) as jul, ; >> sum(iif(month(receiveddate)=8,amount,000000000000.00)) as aug, ; >> sum(iif(month(receiveddate)=9,amount,000000000000.00)) as sep, ; >>>>So far I have not been able to figure out how to work the IIF statements into the new code. Can someone give me some ideas here?