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 |
galbrecht
Starting Member
17 Posts |
Posted - 2008-02-06 : 19:50:16
|
Hi allI would like to select data and have the results displayed in one line not three.The query I am using is as followsSELECT CORP_MASTER__ID, (case when CORP_MAST_LOS = 'G' then CORP_MAST_PROPORTION end) 'Growth',(case when CORP_MAST_LOS = 'L' then CORP_MAST_PROPORTION end) 'Level of Service',(case when CORP_MAST_LOS = 'R' then CORP_MAST_PROPORTION end) 'Renewals'FROM CORP_MASTER__CORP_MAST_LOSWHERE (CORP_MASTER__ID LIKE 'WS%')but the result display three (3) rows prer ID (see beloa)ID Growth LoL RenewalWS01 0 NULL NULLWS01 NULL 100 NULLWS01 NULL NULL 0WS02 0 NULL NULLWS02 NULL 100 NULLWS02 NULL NULL 0WS03 100 NULL NULLWS03 NULL 0 NULLWS03 NULL NULL 0I would like it to be displayed as followsID Growth LoL RenewalWS01 0 100 0WS02 0 100 0WS03 100 0 0Can anyone help please. Thank youGreg |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-02-06 : 20:01:36
|
SELECT CORP_MASTER__ID, max((case when CORP_MAST_LOS = 'G' then CORP_MAST_PROPORTION end)) 'Growth',max((case when CORP_MAST_LOS = 'L' then CORP_MAST_PROPORTION end)) 'Level of Service',max((case when CORP_MAST_LOS = 'R' then CORP_MAST_PROPORTION end)) 'Renewals'FROM CORP_MASTER__CORP_MAST_LOSWHERE (CORP_MASTER__ID LIKE 'WS%')GROUP BY CORP_MASTER__IDBe One with the OptimizerTG |
 |
|
galbrecht
Starting Member
17 Posts |
Posted - 2008-02-06 : 21:47:48
|
Thanks TGYoure a legendGreg |
 |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-02-06 : 22:38:05
|
only in my own mind - but thanks for the feedback Be One with the OptimizerTG |
 |
|
|
|
|