Reputation: 5
I can't get the STRING_AGG() clause to work. I get the error: "SELECT list expression references consignment_items.receiver_id which is neither grouped nor aggregated at [3:1]"
SELECT
table1.field1 AS alias1,
table1.field2,
table1.field3,
table2.field4,
table2.field5 AS alias2,
STRING_AGG(table3.field9, '|') AS alias3
FROM database.table1 table1
JOIN database.table3 roles ON table1.field1 = table3.field6
JOIN database.table2 ON table1.field2 = table2.field7
Upvotes: 0
Views: 2229
Reputation: 1269445
You need GROUP BY
. This will work:
GROUP BY 1, 2, 3, 4, 5
Upvotes: 2