Skip to content
Advertisement

Split Array Into Parts – Get all Unique Items – GoogleSQL

I’m looking to take a String-Array field in Google SQL and transpose it to show all in one column. From there I can take all unique/distinct items from it.

the image above is a sample of what I am trying enter image description here

I can’t get the string array to split out into resulting rows.

Any help or suggestions would be greatly appreciated

Advertisement

Answer

I think you can do it using unnest, assuming columnB is holding the array:

select numbers 
from yourtable t
cross join unnest(t.ColumnB) numbers

and for distinct :

select distinct numbers 
from yourtable t
cross join unnest(t.ColumnB) numbers
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement