How does listagg work in starburst? I am familiar with how in SQL but the similiar fails in starburst. trying to do the below.
LISTAGG (TYP.DESC_NM,‘,’)
How does listagg work in starburst? I am familiar with how in SQL but the similiar fails in starburst. trying to do the below.
LISTAGG (TYP.DESC_NM,‘,’)
From looking at your example I initially got the impression you want to tokenize the value of DESC_NM
by commas and thought what you needed was the split
command, String functions and operators — Trino 475 Documentation, which would work a bit like this…
SELECT custkey, phone,
split(phone, '-') AS phone_parts
FROM tpch.tiny.customer LIMIT 5;
BUT… now I’m guessing you have a nested table or something? Can you give a bit more example of what your table and data look like?
As for listagg
, Aggregate functions — Trino 475 Documentation, itself maybe an example (using a flat table) is better than trying to explain it. Let’s use a list of nations that each belong to a particular region.
SELECT * FROM tpch.tiny.nation;
Aggregate together in a delimited list (I’m using a semicolon) all the nations for a particular region.
SELECT regionkey,
LISTAGG(ALL name, '; ')
WITHIN GROUP (ORDER BY name)
AS nation_list
FROM tpch.tiny.nation
GROUP BY regionkey
ORDER BY regionkey;
Let me know if you are still looking for some help.