0

I have formed a large query which fetches a large data set with the below data condition.

Column1 Column2  
M1        OTH  
M1        HHM  
M1        RES  
M2        HHM  
M2        RES  
M3        OTH  
M3        RES  

I need to form it as:

M1        OTH,HHM,RES  
M2        HHM,RES  
M3        OTH,RES  

Any help would be appreciated.

1 Answer 1

2

You can use one of the available string aggregation techniques described in this document.

For instance:

SELECT COLUMN1, LISTAGG(COLUMN2, ',') WITHIN GROUP (ORDER BY COLUMN1) AS COLUMN2s
FROM TABLE
GROUP BY COLUMN1;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.