Author: bshkris
Subject: DB2 SQL help/idea/suggestion
Posted: Thu Oct 06, 2016 3:04 pm (GMT 5.5)
Hi,
I have table A. the data looks like below
the final result should be as below. the val1, val2 columns must have sum of values based upon the O_ID whether it has matching or not.
BCCR59 is new MSR TYP CD which is combination of BCCR19 + BCCR20 +BCCR21.
Please post your ideas and suggestion how we can do it in DB2 SQL.
Thanks.
CODE' D
_________________
hi, good luck, keep in touch
Subject: DB2 SQL help/idea/suggestion
Posted: Thu Oct 06, 2016 3:04 pm (GMT 5.5)
Hi,
I have table A. the data looks like below
Code: |
O_ID MSR_TYP_CD MSR_VAL_1_QT MSR_VAL_2_QT 1 BCCR19 1 23 2 BCCR19 1 24 3 BCCR19 0 23 4 BCCR19 0 23 |
Code: |
O_ID MSR_TYP_CD MSR_VAL_1_QT MSR_VAL_2_QT 1 BCCR20 1 1 56 BCCR20 4 45 33 BCCR20 0 0 45 BCCR20 0 0 |
Code: |
O_ID MSR_TYP_CD MSR_VAL_1_QT MSR_VAL_2_QT 56 BCCR21 6 0 67 BCCR21 1 0 44 BCCR21 1 0 1 BCCR21 1 1 |
the final result should be as below. the val1, val2 columns must have sum of values based upon the O_ID whether it has matching or not.
Code: |
O_ID MSR_TYP_CD MSR_VAL_1_QT MSR_VAL_2_QT 1 BCCR59 3 25 2 BCCR59 1 0 3 BCCR59 0 23 4 BCCR59 0 23 33 BCCR59 0 0 45 BCCR59 0 0 56 BCCR59 10 45 67 BCCR59 1 0 |
BCCR59 is new MSR TYP CD which is combination of BCCR19 + BCCR20 +BCCR21.
Please post your ideas and suggestion how we can do it in DB2 SQL.
Thanks.
CODE' D
_________________
hi, good luck, keep in touch