Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
Concat multiple rows PSQL
     id  |     name      |   Subject   | Lectured_Times |     Faculty                      
 3258132 | Chris Smith   | SATS1364    |     10         | Science 
 3258132 | Chris Smith   | ECTS4605    |      9         | Engineering

How would I go about creating the following

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

where the + is just a new line. Notice how after the '+'(new line) it doesnt concat the id,name

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

try

SELECT distinct concat(id,"name",string_agg(concat(subject, Lectured_Times , Faculty), chr(10))) 
from tn 
where id = 3258132 
group by id;
over 4 years ago · Santiago Trujillo Report

0

As mentioned above string_agg is perfect solution for this.

select 
    id, name, string_agg(concat(subject, Lectured_Times, Faculty), '\n')
from table
group by id, name
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!