First I will present example of what I'm trying to achieve, and then will share a bit more info. This is a relatively straightforward task to explain, however I am new to BigQuery and am not sure if the task is simple to implement or not.
I have a dataset of names and am attempting to concat the names into a single column, however the names need to be sorted first. The dataset looks as such:
p1 p2 p3 p4
Nick Tom Joe Chris
Sal Bill Tom Joe
Nick Joe Chris Sal
Nick Joe Joe Chris
I'd like to create a 5th column that concats p1, p2, p3 and p4 in a sorted manner so that the output is as such:
p1 p2 p3 p4 concat_col
Nick Tom Joe Chris Chris_Joe_Nick_Tom
Sal Bill Tom Joe Bill_Joe_Sal_Top
Nick Joe Chris Sal Chris_Joe_Nick_Sal
Nick Joe Tom Chris Chris_Joe_Nick_Top
Currently I have the following
SELECT
p1, p2, p3, p4,
concat(p1, '_', p2, '_', p3, '_', p4) as concat_col
FROM
my_table
...and this concats the columns but obviously doesn't do so in a sorted manner.