Hello all,
My project requires me to build a single query for making some multiple field calculations. Also tried to build a Query which is as below
SELECT
sum(case when LDGR_NO in (311000,312000) then LDGR_BAL_AM else 0 end) as Sum1
sum(case when LDGR_NO in (911000,912000) then LDGR_BAL_AM else 0 end) as Sum2
sum(case when LDGR_NO in (314000, 312000, 414000,454000) then LDGR_BAL_AM else 0 end) as Sum3
FROM DEVL8SGA.A_SGA_GRP_PSTN_SNP
WHERE ACCT_GRP_NO = 2100099
AND ACCT_NO = 791189
AND LDGR_NO IN (311000, 312000,911000, 912000,314000, 312000, 414000,454000 )
(The above query SHOULD return 3 values (Sum1, Sum2 Sum3) which are GOT by adding up the ldgr_bal_am for 3 sets of ledger numbers found.
Tried to execute this in Db2, but it didnt work. Showed an error in 'case when LDGR_NO in (311000,312000) ....' Can anyone help me in this query and also suggest if there is any other way to Query this in Db2?.
Thanks.
My project requires me to build a single query for making some multiple field calculations. Also tried to build a Query which is as below
SELECT
sum(case when LDGR_NO in (311000,312000) then LDGR_BAL_AM else 0 end) as Sum1
sum(case when LDGR_NO in (911000,912000) then LDGR_BAL_AM else 0 end) as Sum2
sum(case when LDGR_NO in (314000, 312000, 414000,454000) then LDGR_BAL_AM else 0 end) as Sum3
FROM DEVL8SGA.A_SGA_GRP_PSTN_SNP
WHERE ACCT_GRP_NO = 2100099
AND ACCT_NO = 791189
AND LDGR_NO IN (311000, 312000,911000, 912000,314000, 312000, 414000,454000 )
(The above query SHOULD return 3 values (Sum1, Sum2 Sum3) which are GOT by adding up the ldgr_bal_am for 3 sets of ledger numbers found.
Tried to execute this in Db2, but it didnt work. Showed an error in 'case when LDGR_NO in (311000,312000) ....' Can anyone help me in this query and also suggest if there is any other way to Query this in Db2?.
Thanks.