1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| SELECT
CA.C6 AS "CP Ownership",
'BCA' as "Type",
SUM(T.COM) as "Value"
FROM
CAWP CA, CAWP WP, TPHASE T
WHERE
CA.PROGRAM = '2006HSBC'
AND CA.PROGRAM = WP.PROGRAM
AND CA.CA1=WP.CA1
AND CA.CA2=WP.CA2
AND CA.CA3=WP.CA3
AND CA.WP=' '
AND CA.C6!=' '
AND WP.WP>' '
AND T.PROGRAM = WP.PROGRAM
AND T.CAWPID=WP.CAWPID
AND T.CLASS IN ('B1','B2','B3','B4','B5','B6','B7','B8','B9','CB','EB','G1','G2','G3','HB','J1','J2','J3','S1','S2','S3','SC','TB','V1','V2','V3','V4','V5','V6','V7','V8','V9')
GROUP BY CA.C6
UNION
SELECT
CA.C6 AS "CP Ownership",
'PBC' as "Type",
SUM(T.COM) as "Value"
FROM
CAWP CA, CAWP WP, TPHASE T
WHERE
CA.PROGRAM = '2006HSBC'
AND CA.PROGRAM = WP.PROGRAM
AND CA.CA1=WP.CA1
AND CA.CA2=WP.CA2
AND CA.CA3=WP.CA3
AND CA.WP=' '
AND CA.C6!=' '
AND WP.WP>' '
AND T.PROGRAM = WP.PROGRAM
AND T.CAWPID=WP.CAWPID
AND T.CLASS IN ('P1','P2','P3','P4','P5','P6','P7','P8','P9','PB')
GROUP BY CA.C6
UNION
SELECT
CA.C6 AS "CP Ownership",
'UNAPPROVED_RESIDUAL' as "Type",
SUM(T.COM) as "Value"
FROM
CAWP CA, CAWP WP, TPHASE T
WHERE
CA.PROGRAM = '2006HSBC'
AND CA.PROGRAM = WP.PROGRAM
AND CA.CA1=WP.CA1
AND CA.CA2=WP.CA2
AND CA.CA3=WP.CA3
AND CA.WP=' '
AND CA.C6!=' '
AND WP.WP>' '
AND T.PROGRAM = WP.PROGRAM
AND T.CAWPID=WP.CAWPID
GROUP BY CA.C6 |
Partager