Lecture

Filter Events with Above-Average Ticket Sales

The events team wants to know which events are performing above average in terms of total ticket revenue.

You’ll use GROUP BY with SUM() to calculate total sales per event, and then apply a HAVING clause containing a subquery to compare each event’s total to the overall average.

This combination of HAVING and subqueries is a common way to find high-performing categories or entities in SQL.


Task

From the purchases table in the event_ticketing.sqlite database, display:

  • event_id

Include only events whose total ticket revenue is higher than the average total revenue across all events.


How to solve it

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.

sqlQuiz
?

Lecture

AI Tutor

Design

Upload

Notes

Favorites

Help

Code Editor

Run
Generate

Tables

Execution Result