SELECT with intermediate table returning all values in the same field and separated by comma

Asked

Viewed 202 times

1

I have the tables (and their relationships) of the diagram below:Diagrama

I need to do this: Bring all the fields of the TBCADCRE table and an extra column called ADQ with all the TIPADQ that the user has (can have a maximum of 6) separated by ",".

To improve understanding, I made a select with the 3 tables, but it returns a row for each TIPADQ that the user has (image below).

ADQs

I need to bring a single line and all Tipadqs within the same field separated by ",". Ex: CIELO,STONE,POS...

Can anyone help me? Thank you.

  • You can always get inside one loop or cursor fill in the column TIPADQ concatenating all lines into one.

  • Thanks João! I will search for loop in SQL and then update here! ;)

  • Possible duplicate of Concatenate results

1 answer

1


After several attempts and mistakes, I solved as follows:

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.