Basit Khan

Basit Khan

  • NA
  • 336
  • 121.6k

Printing Column in SQL

Sep 17 2015 12:52 AM
Dear,
 

I have a table called Dummy, On that column are Dm_Ex, Dm_SL, Dm_Ad all data type numeric.

What I want if Dm_Ex>0 then ‘Ex’ if Dm_SL>0 then ‘SL’ if Dm_Ad>0 then ‘AD’

Dm_Ex

Dm_SL

Dm_Ad

Result Want

1

0

1

EX,AD

1

1

1

EX,SL,AD

0

1

1

SL,AD

1

0

0

EX

I used case but not success.

CASE WHEN Dm_Ex > 0 THEN 'EX' WHEN Dm_SL > 0 THEN 'SL' WHEN Dm_Ad > 0 THEN 'AD' ELSE 'N/A' END

Thanks
Basit. 

Answers (2)