Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Join rows Google BigQuery

I have a huge table (i.e. 3 million rows) in Google BigQuery. The structure is something like this:

name1    attribute1
name2    attribute2
name1    attribute2

I'd now like to get a list per name of the attributes that they have. So for the example above, I would want something like this:

name1    attribute1, attribute2
name2    attribute2

Is this possible with BigQuery (so without having to write any code, just purely as an SQL query)?

like image 587
danielvdende Avatar asked Sep 25 '26 05:09

danielvdende


1 Answers

I suggest that you use the GROUP_CONCAT function:

SELECT name, GROUP_CONCAT(columnNameContainingTheAttribute)
FROM yourTable
GROUP BY name

You can learn more about the GROUP_CONCAT function here: https://developers.google.com/bigquery/query-reference?hl=FR#aggfunctions

like image 104
YABADABADOU Avatar answered Sep 26 '26 18:09

YABADABADOU



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!