I want to list what brands each customer buys. I have the same "customer_id" feilds showing up repeatedly with a name of different brands (shown as column title: "name") they purchased in this code. I'd like to group by the customer_id and show a list of brands for each customer_id. I get the error message:
"ERROR: function group_concat(character varying, unknown) does not exist ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.
CREATE TEMP TABLE customer_brandids AS
SELECT receipts.receipt_id, receipts.customer_id, receipt_item_details1.brand_id
FROM receipts
LEFT JOIN receipt_item_details1
ON receipts.receipt_id = receipt_item_details1.receipt_id;
SELECT customer_brandids.customer_id, customer_brandids.brand_id, brands.name, GROUP_CONCAT(brands.name,',')
FROM customer_brandids
INNER JOIN brands
ON customer_brandids.brand_id = brands.brand_id
GROUP by customer_id