I have a Retool database. When using GROUP BY COLUMN1, COLUMN2, I want to aggregate COLUMN3, which contains strings. As far as I can tell, this requires that I aggregate COLUMN3.
It appears that some SQLs have a STRING_AGG function. However, Retool does not recognize this. How do I aggregate the COLUMN3 strings when using GROUP BY?
I should have used “aggregate” rather than “concatenate” in the title.
The || operator concatenates strings, but it does not aggregate strings, which I need for the GROUP BY.
The voters table has columns for first name, last name, street number, and street name, &c. I need to create a mailing list that, for each address, has a field that combines all the names into one string, which is what STRING_AGG apparently would do.
SELECT
-- Aggregate Names here,
streetnumber,
streetname
FROM voters
GROUP BY streetnumber,streetname
;
SELECT
streetnumber,
streetname,
STRING_AGG(name1, ',') AS aggregated_name1,
STRING_AGG(name2, ',') AS aggregated_name2
FROM voters
GROUP BY streetnumber, streetname;
But are you trying to concatenate all names as one field?