Hello all,
Please look at Query1, in which I would like to add more CASE statements.
Query1
SELECT CASE WHEN LDGR_NO = 800100 THEN LDGR_BAL_AM ELSE NULL END AS TRADE1 FROM DEVL8SGA.A_SGA_GRP_PSTN_SNP WHERE ACCT_NO = 791189 AND LDGR_NO = 800100
(When I execute the above query there are multiple records/rows pulled up. The result of the query is displayed below.
TRADE1
-----------
2200.0000
21000.0000
2700.0000
2000.0000
38000.0000
11000.0000
126000.0000
28000.0000
137500.0000
32700.0000
40000.0000
etc
For the same query above, I would like to add multiple cases like
Query2
SELECT CASE WHEN LDGR_NO = 800100 THEN LDGR_BAL_AM ELSE NULL END AS TRADE1,
CASE WHEN LDGR_NO = 800200 THEN LDGR_BAL_AM ELSE NULL END AS TRADE2
FROM DEVL8SGA.A_SGA_GRP_PSTN_SNP
WHERE ACCT_NO = 791189 AND LDGR_NO IN(800100,800200)
But the result that i am getting is
TRADE1 TRADE2
--------------------------- ---------------------------
2200.0000 -
21000.0000 -
2700.0000 -
2000.0000 -
38000.0000 -
11000.0000 -
126000.0000 -
28000.0000 -
137500.0000 -
32700.0000 -
40000.0000 -
21800.0000 -
430000.0000 -
400000.0000 -
TRADE1 TRADE2
---------------------------++---------------------------
12900.0000 -
4100.0000 -
24000.0000 -
- 2200.0000
- 21000.0000
- 2700.0000
- 2000.0000
- 38000.0000
- 11000.0000
- 126000.0000
- 28000.0000
- 137500.0000
- 32700.0000
- 40000.0000
- 21800.0000
- 430000.0000
The result that I would like to get is (parallel to each other)
TRADE1 TRADE2
--------------------------- ---------------------------
2200.0000 2200.0000
21000.0000 21000.0000
2700.0000 2700.0000
2000.0000 2000.0000
Please let me know how i could change my query(Query2) so that i can use multiple cases in the Query statement and have all the columns displayed parallel to each other.
Thanks
sheetal
Please look at Query1, in which I would like to add more CASE statements.
Query1
SELECT CASE WHEN LDGR_NO = 800100 THEN LDGR_BAL_AM ELSE NULL END AS TRADE1 FROM DEVL8SGA.A_SGA_GRP_PSTN_SNP WHERE ACCT_NO = 791189 AND LDGR_NO = 800100
(When I execute the above query there are multiple records/rows pulled up. The result of the query is displayed below.
TRADE1
-----------
2200.0000
21000.0000
2700.0000
2000.0000
38000.0000
11000.0000
126000.0000
28000.0000
137500.0000
32700.0000
40000.0000
etc
For the same query above, I would like to add multiple cases like
Query2
SELECT CASE WHEN LDGR_NO = 800100 THEN LDGR_BAL_AM ELSE NULL END AS TRADE1,
CASE WHEN LDGR_NO = 800200 THEN LDGR_BAL_AM ELSE NULL END AS TRADE2
FROM DEVL8SGA.A_SGA_GRP_PSTN_SNP
WHERE ACCT_NO = 791189 AND LDGR_NO IN(800100,800200)
But the result that i am getting is
TRADE1 TRADE2
--------------------------- ---------------------------
2200.0000 -
21000.0000 -
2700.0000 -
2000.0000 -
38000.0000 -
11000.0000 -
126000.0000 -
28000.0000 -
137500.0000 -
32700.0000 -
40000.0000 -
21800.0000 -
430000.0000 -
400000.0000 -
TRADE1 TRADE2
---------------------------++---------------------------
12900.0000 -
4100.0000 -
24000.0000 -
- 2200.0000
- 21000.0000
- 2700.0000
- 2000.0000
- 38000.0000
- 11000.0000
- 126000.0000
- 28000.0000
- 137500.0000
- 32700.0000
- 40000.0000
- 21800.0000
- 430000.0000
The result that I would like to get is (parallel to each other)
TRADE1 TRADE2
--------------------------- ---------------------------
2200.0000 2200.0000
21000.0000 21000.0000
2700.0000 2700.0000
2000.0000 2000.0000
Please let me know how i could change my query(Query2) so that i can use multiple cases in the Query statement and have all the columns displayed parallel to each other.
Thanks
sheetal