1
I have the following select:
SELECT c.codigo
,c.situacao
,c.fk_aluno
FROM tb_cad AS c
INNER JOIN tb_aluno AS a ON c.fk_aluno = a.id
order by c.fk_aluno
I need when c.fk_aluno
is equal, agglutinate all c.codigo
in a single line.
Select return example above:
17162 A 74
17045 A 75
17177 A 75
17175 A 75
17174 A 75
17182 I 75
I need you to c.fk_aluno
is repeated, join in a row and concatenate
17162 A 74
17045 A, 17177 A,17175 A, 17174 A, 17182 I 75
Using SQL Server 2012
Let us know your database! So we can help you in a better way...
– Matheus Ribeiro
sql server 2012
– user141448
Beauty, when so edit your question and put that information there, you can do by link
– Matheus Ribeiro
Possible duplicate of Concatenate results
– Sorack
But do you want everything in the same column? Or the columns
codigo
andsituacao
is in one column and thefk_aluno
in a separate?– João Martins
code and situation is in one column and fk_pupil in another separate
– user141448
If the answer below solves your problem, give an UP and mark it as right! (I give this statement here because @user141448 edited my reply to inform that solved the problem).
– João Martins