Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query Nulls

Status
Not open for further replies.

jrprogr

Programmer
Jul 20, 2006
74
US
Below is my query which will diplay the results.

select E.Colname
,max( case when CRF.RCD = '02' then CRF.RCD else null end)'Sm02'
,max( case when CRF.RCD = '03' then CRF.RCD else null end)'S03'
,max( case when CRF.RCD = '01' then CRF.RCD else null end)'I01'
,max( case when CRF.RCD = '04' then CRF.RCD else null end)'N04'

from tablename

Results:

Sm02 S03 I01 N04
----- ---- --- ----
02 NULL NULL 04
NULL NULL 01 NULL
02 NULL NULL NULL
02 NULL NULL NULL
02 03 01 NULL



I want the results: (when there is no values instead of null it should display empty)



Sm02 S03 I01 N04
----- ---- --- ----
02 04
01
02
02
02 03 01
 
It Got the desired output by the following changes


select E.Colname
,max( case when CRF.RCD = '02' then CRF.RCD else '' end)'Sm02'
,max( case when CRF.RCD = '03' then CRF.RCD else '' end)'S03'
,max( case when CRF.RCD = '01' then CRF.RCD else '' end)'I01'
,max( case when CRF.RCD = '04' then CRF.RCD else '' end)'N04'

from tablename

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top