Filter Events with Above-Average Ticket Sales
You're helping the events team identify which events are performing well in terms of total revenue.
They want a list of event IDs where the total ticket sales are above the average across all events.
To get this insight, you'll use GROUP BY
and SUM()
to calculate total sales per event, and then apply a HAVING
clause with a subquery to compare each total to the overall average.
What to Show
From the purchases
table in the event_ticketing.sqlite
database, return:
event_id
Only include events where the total ticket revenue is greater than the average total revenue per event.
Instructions
Write a SQL query that groups purchases by event_id
, calculates total revenue with SUM(price)
, and filters with HAVING
using a subquery that computes the average total sales.
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help
Code Editor
Tables
Execution Result