Quantcast
Channel: IBM Mainframe Computers Forums
Viewing all articles
Browse latest Browse all 8500

DB2 :: Require help in DB2 Query

$
0
0
Author: Shruti Takkar
Subject: Require help in DB2 Query
Posted: Wed Aug 03, 2016 10:57 pm (GMT 5.5)

Hi ,

I have to execute below problem in DB2 query, please suggest some valuable options.

Consider Table A having account details.
I need to count accounts from Table A for multiple scenarios.

I can count accounts using multiple case when conditions like below.
===========================================
select Count(case when t1.a = 1 then 1 else 0 end) as A_COUNT
, Count(case when t1.b = 2 then 1 else 0 end) as B_COUNT
from t1
============================================

My problem here is,, if my account is counted in A_COUNT, it should not get double counted in B_COUNT.

There are multiple when conditions and it is not possible to tweak them to make all conditions mutually exclusive.

Regards,
Shruti


Viewing all articles
Browse latest Browse all 8500

Trending Articles