How can I group multiple records as a single .csv string line?
0
votes
1
answer
929
views
I have a relation where a User has multiple dogs (as many as 15) but each dog is contained in a single row in the table, and they all have a userId in common.
For example, Table
dogs
:
| User | Dog Name | Age
| ABCD | Fido | 7
| ABCD | Gooofy | 9
| ABCD | Toto | 4
| ABCD | Roger | 12
| ABCD | Barkley | 3
I would like to do something like SELECT * FROM dogs GROUP BY User
where the result will output a csv of ABCD
s dogs, as follows:
ABCD, Fido, 7, Goofy, 9, Toto, 4, Roger, 12, Barkley, 3
I'm using BigQuery but I think knowing how to do this in PostgreSQL may even be helpful. So maybe I can create some sort of view or something?
Asked by Kamilski81
(231 rep)
Jul 1, 2021, 09:53 PM
Last activity: Jul 2, 2021, 12:05 PM
Last activity: Jul 2, 2021, 12:05 PM