Hi
DB2 v9.5 z/os
Please find the all scenario and guide me to write a Select query to filter the records.
cond:
1. eliminate all records which VOL_COUNT will have ZERO values
2.Dispaly one record if all records having VOL_COUNT as ZERO values
3. by all the times, the record which is having P.LOC as 'XXX' should be elimated if the NUMBER (NO_FIRST,NO_MID,NO_LAST)
having more than one occurence
4.Dispaly if the number(NO_FIRST,NO_MID,NO_LAST) having the only one record like P_LOC as 'XXX'
Thanks
DB2 v9.5 z/os
Please find the all scenario and guide me to write a Select query to filter the records.
cond:
1. eliminate all records which VOL_COUNT will have ZERO values
2.Dispaly one record if all records having VOL_COUNT as ZERO values
3. by all the times, the record which is having P.LOC as 'XXX' should be elimated if the NUMBER (NO_FIRST,NO_MID,NO_LAST)
having more than one occurence
4.Dispaly if the number(NO_FIRST,NO_MID,NO_LAST) having the only one record like P_LOC as 'XXX'
Code:
SELECT
T1.P_LOC
,T1.NO_FIRST
,T1.NO_MID
,T1.NO_LAST
,T1.VOL_COUNT
FROM BASE_TABLE T1
WHERE
T1.NO_FIRST = '111'
AND T1.NO_MID = '222'
AND T1.NO_LAST ='333'
Code:
BASE_TABLE
P.LOC NO_FIRST NO_MID NO_LAST VOL_COUNT
A11 111 222 333 1200
B11 111 222 333 0
C11 111 222 333 0
XXX 111 222 333 0
EXPECTED OUTPUT
P.LOC NO_FIRST NO_MID NO_LAST VOL_COUNT
A11 111 222 333 1200
BASE_TABLE
P.LOC NO_FIRST NO_MID NO_LAST VOL_COUNT
A11 111 222 333 0
B11 111 222 333 0
C11 111 222 333 0
XXX 111 222 333 0
EXPECTED OUTPUT
P.LOC NO_FIRST NO_MID NO_LAST VOL_COUNT
A11 111 222 333 0
BASE_TABLE
P.LOC NO_FIRST NO_MID NO_LAST VOL_COUNT
A11 111 222 333 1200
B11 111 222 333 1300
C11 111 222 333 1400
XXX 111 222 333 0
EXPECTED OUTPUT
P.LOC NO_FIRST NO_MID NO_LAST VOL_COUNT
A11 111 222 333 1200
B11 111 222 333 1300
C11 111 222 333 1400
BASE_TABLE
P.LOC NO_FIRST NO_MID NO_LAST VOL_COUNT
XXX 111 222 333 0
EXPECTED OUTPUT
P.LOC NO_FIRST NO_MID NO_LAST VOL_COUNT
XXX 111 222 333 0