cse statements

Training

cse statements


TABLE A
COL1 COL2 COL3 RESULT
1234 34 45 2
12 54 FD 2
34 78 DF 2
45 87 GF 2
21 787 YT 2
454 8 ER 2
56 7 H 2
3
3
3
IF COLUMN 1 IS NOT NULL THEN '02' 3
IF COLUMN 2 IS NOT NULL THEN '03' 3
IF COLUMN 3 IS NOT NULL THEN '04' 3
3
4
4
4
4
4
4
4

USING SELECT STATEMENT I SHOULD GET 12 ROWS IN ASINGLE COLUMN

CAN ANY GIVE THE QUERY..?
2 REPLIES

Re: cse statements

TABLE A

PARG GRUP SUBG
23 56 456
43 7R RE
556 TR 56
667 34 45
78 N2 45

IF COL1 IS NOT NULL THEN '02'
IF COL2 IS NOT NULL THEN '03'
IF COL3 IS NOT NULL THEN '04'

THEREFORE I SHOULD GET 15 ROWS..

RESULT
02
02
02
02
02
03
03
03
03
03
03
04
04
04
04
04
Junior Contributor

Re: cse statements

It's hard to understand what you are trying to achieve.

It might be some UNIONs:

select '02' from tab where column1 is not null
union all
select '03' from tab where column2 is not null
union all
select '04' from tab where column3 is not null

If this doesn't help, please provide DDL & Inserts & more explanation.

Dieter