I have a query to display some values. I used LISTAGG statement. But the output I expect is little different. Please help me out.
Select EMP_NAME, EMP_SKILL, LISTAGG(SUBJECT_NAME, ', ')
WITHIN GROUP (ORDER BY EMP_SKILL) as EMP_SUBJECT_SKILL fromEMPLOYEE group by EMP_NAME, EMP_SKILL;
Actual Output:
| EMP_NAME | EMP_SKILL | SUBJECT_NAME |
| Abhilash K | P1 | Maths |
| Anand P | P1 | Physics |
| Anand P | P2 | Maths, Zoology |
| Arun Kumar | P1 | Geography |
| Arun Kumar | P2 | Maths, History, Civics |
| Arun Kumar | P3 | Hindi |
| | |
Expected Output:
| EMP_NAME | EMP_SKILL | SUBJECT_NAME |
| Abilash K | P1 | Maths |
| Anand P | P1 | Physics |
| Anand P | P2 | Maths, |
Zoology |
| Arun Kumar | P1 | Geography |
| Arun Kumar | P2 | Maths, |
| History, |
Civics |
| Arun Kumar | P3 | Hindi |
I already read a post but I could not achieve it. Could anyone please suggest how to do it.
Thanks in advance.