December 19, 2005 at 9:27 pm
Hello all,
My project requires me to build a single query for making some multiple field calculations. Also tried to build a Query with the help of a member here 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 returns 3 values (Sum1, Sum2 Sum3) which are 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.
SQLServerCentral's forums.
December 22, 2005 at 5:15 am
I have just had a look at the DB2 for LUW SQL Reference manual and your query should work.
However, you need to be aware that DB2 running on the mainframe, and DB2 running on AS\400 is a different code base and not all syntax is supported on those platforms. In any DB2 question is is useful to say what the target DB2 instance is running on, and the DB2 version.
You may get a better response posting your question in a dedicated DB2 forum, as most people looking at this forum know little about DB2.
Original author: https://github.com/SQL-FineBuild/Common/wiki/ 1-click install and best practice configuration of SQL Server 2019, 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005.
When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist - Archbishop Hélder Câmara
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply