Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda