id | name | Subject | Lectured_Times | Faculty
3258132 | Chris Smith | SATS1364 | 10 | Science
3258132 | Chris Smith | ECTS4605 | 9 | Engineering
我将如何创建以下
3258132 Chris Smith SATS1364, 10, Science + ECTS4605, 9,Engineering
其中+只是一个新行。注意在' +'(新行)之后它不会连接id,名称
答案 0 :(得分:0)
试
SELECT distinct concat(id,"name",string_agg(concat(subject, Lectured_Times , Faculty), chr(10)))
from tn
where id = 3258132
group by id;
答案 1 :(得分:0)
如上所述,string_agg是完美的解决方案。
[dividerColor]="'primary'"