2017-04-27 3 views
0
 id |  name  | Subject | Lectured_Times |  Faculty      
3258132 | Chris Smith | SATS1364 |  10   | Science 
3258132 | Chris Smith | ECTS4605 |  9   | Engineering 

은 어떻게 + 그냥 새로운 라인입니다 다음CONCAT 여러 행 PSQL

3258132 Chris Smith SATS1364, 10, Science + ECTS4605, 9,Engineering 

를 만드는 방법에 대해 갈 것입니다.

+0

string_agg() 함수를 사용할 수 있습니다. 이것을 확인하십시오 http://stackoverflow.com/questions/12370083/concat-rows-in-postgres –

답변

0

string_agg 위에서 언급 한 바와 같이
SELECT distinct concat(id,"name",string_agg(concat(subject, Lectured_Times , Faculty), chr(10))) 
from tn 
where id = 3258132 
group by id; 
0

이를위한 완벽한 솔루션입니다하려고 이름, '+'(새로운 라인) 후에는 ID CONCAT 나던 방법을 알 수 있습니다.

select 
    id, name, string_agg(concat(subject, Lectured_Times, Faculty), '\n') 
from table 
group by id, name