Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ayadav0984
Starting Member
21 Posts |
Posted - 2011-05-10 : 03:41:32
|
| Can anybody provide me a way to fetch all the months irrespective of the fact whether it matches the where clause criteria ina group by statement? The query created by me is :select Ret_fm, isnull(sum(case when TrnxMnth ='APR-10' then return_ppt end)/100000,0) as [APR-10],isnull(sum(case when TrnxMnth ='MAY-10' then return_ppt end)/100000,0) as [MAY-10],isnull(sum(case when TrnxMnth ='JUN-10' then return_ppt end)/100000,0) as [JUN-10],isnull(sum(case when TrnxMnth ='JUL-10' then return_ppt end)/100000,0) as [JUL-10],isnull(sum(case when TrnxMnth ='AUG-10' then return_ppt end)/100000,0) as [AUG-10],isnull(sum(case when TrnxMnth ='SEP-10' then return_ppt end)/100000,0) as [SEP-10],isnull(sum(case when TrnxMnth ='OCT-10' then return_ppt end)/100000,0) as [OCT-10],isnull(sum(case when TrnxMnth ='NOV-10' then return_ppt end)/100000,0) as [NOV-10],isnull(sum(case when TrnxMnth ='DEC-10' then return_ppt end)/100000,0) as [DEC-10],isnull(sum(case when TrnxMnth ='JAN-11' then return_ppt end)/100000,0) as [JAN-11],isnull(sum(case when TrnxMnth ='FEB-11' then return_ppt end)/100000,0) as [FEB-11],isnull(sum(case when TrnxMnth ='MAR-11' then return_ppt end)/100000,0) as [MAR-11],isnull(sum(case when TrnxMnth ='APR-11' then return_ppt end)/100000,0) as [APR-11] from dbo.COMMISSION_DB_APR10_APR11 where product_cat='electronics - cameras' and channel not in ('web','web cc','web pp','web ie') and brand IN ('sony') group by Ret_fm |
|
|
ayadav0984
Starting Member
21 Posts |
Posted - 2011-05-10 : 03:44:19
|
| the result which i am getting is only those months in ret_fm field which matches the where clause criteria.Ia there a way through which we can manipulate the months which do not match the criteria. |
 |
|
|
|
|
|
|
|