Hello,

Below is a solution
regexp_replace(array_join(sort_array(array_agg(concat(hist, alf))), ' -> '),'[0-9]','')

The idea in the code is to concatenate the "hist" column with the "alf" column, this way the "sort_array" can sort based on the numbers in the "hist" column and finally a "regexp_replace" is done removing the numbers from the "hist" column. hist" as they cannot be shown in the final result

Hope this helps

 

ThomazRossito_0-1712704018151.png

 

Att.
Thomaz Antonio Rossito Neto
Master Data Specialist - Data Architect | Data Engineer @ CI&T

View solution in original post