The code runs ok when i don't have the last line (GROUP BY ch.name). When I include the line I receive an error listed below - I am trying to get a query where I can identify and group many things such as grouping transactions by cardholder and grouping from 7:00 - 9:00 AM EST. Still new to coding so a bit frustrated. Any help is appreciated!
ERROR: column "t.date" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT ch.name, t.date, t.amount, t.card AS "Credit Card", t...
^
SQL state: 42803
Character: 17
My query:
SELECT
ch.name, t.date, t.amount, t.card AS "Credit Card", t.id_merchant,
m.name AS "Merchan, mc.name AS "merchant category"
FROM
transaction AS t
JOIN
credit_card AS cc ON (t.card = cc.card)
JOIN
card_holder AS ch ON (cc.cardholder_id = ch.id)
JOIN
merchant AS m ON (t.id_merchant = m.id)
JOIN
merchant_category AS mc ON (m.id_merchant_category = mc.id)
GROUP BY
ch.name;