I have two tables:
Table 1:
id
title
Table 2:
id
Table_1_id
number_of_tickets
I need a query to count the number of tickets from table 2 and show: Table_1_id, title, total_number_of_tickets
I wrote this code but it gives me the error:
"column "plays.title" must appear in the GROUP BY clause or be used in an aggregate function LINE 2: SELECT reservations.play_id AS id , plays.title , SUM(number..."
SELECT reservations.play_id AS id , plays.title , SUM(number_of_tickets) AS reserved_tickets FROM plays
INNER JOIN reservations
ON plays.id = reservations.play_id
GROUP BY play_id
ORDER BY SUM(number_of_tickets)