id | name | Subject | Lectured_Times | Faculty 3258132 | Chris Smith | SATS1364 | 10 | Science 3258132 | Chris Smith | ECTS4605 | 9 | Engineering¿Cómo haría para crear lo siguiente?
3258132 Chris Smith SATS1364, 10, Science + ECTS4605, 9,Engineeringdonde el + es solo una nueva línea. Observe cómo después del '+' (nueva línea) no concatena la identificación, el nombre
tratar
SELECT distinct concat(id,"name",string_agg(concat(subject, Lectured_Times , Faculty), chr(10))) from tn where id = 3258132 group by id;Como se mencionó anteriormente, string_agg es la solución perfecta para esto.
select id, name, string_agg(concat(subject, Lectured_Times, Faculty), '\n') from table group by id, name