on 06-18-2015 11:39 AM
Hi Norman,
Below is the sample data.
Below is the query that provides the required output.
If you also want all the other fields from the table after aggregation, then use the below query. This has one more INNER JOIN
SELECT T2.CARD_CODE,T2.CARD_NAME,T2.SUM_DOCTOTAL,T2.INV_LIST,T3.COLUMN_1,T3.COLUMN_2,....,T3.COLUMN_N
FROM
(
SELECT T0.CARD_CODE,T0.CARD_NAME,T0.SUM_DOCTOTAL,STRING_AGG(T1.INV,',') AS INV_LIST
FROM
(
SELECT CARD_CODE,CARD_NAME,SUM(DOCTOTAL) AS SUM_DOCTOTAL
FROM <Schema_name>.CARD_MASTER
GROUP BY CARD_CODE,CARD_NAME
) T0
INNER JOIN
<Schema_name>.CARD_MASTER T1
ON
T0.CARD_CODE = T1.CARD_CODE
GROUP BY T0.CARD_CODE,T0.CARD_NAME,T0.SUM_DOCTOTAL
) T2
INNER JOIN
<Schema_name>.CARD_MASTER T3
ON
T2.CARD_CODE = T3.CARD_CODE;
Regards,
Sunny
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What o/p should come for 'C000001'?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.