SQL Playground Mission: Movie Genre Scorecard
Turn rental history into a genre scorecard with counts and revenue.
A scorecard compresses transaction rows into a ranked view of performance. Here, each rental row contributes activity and revenue, while the movie table supplies the genre used for grouping.
The
HAVING
clause keeps the report focused on genres with enough activity to compare.
That is a common playground move: group broadly, then tighten the report
once you can see the shape of the data.
select dimension,
count(*) as activity,
round(sum(amount), 2) as revenue
from fact_table
join dimension_table using (dimension_id)
group by dimension
having count(*) >= 3
order by revenue desc, dimension Schema · Movie Rentals Table · rentals 6 columns · 26 rows
One row per rental. Movies still out have a null returned_date.
Schema Table · movies 5 columns · 12 rows
One row per movie in the catalog.
Build a genre scorecard. Return genre, rentals,
and revenue for genres with at least 3 rentals. Sort by revenue
descending, then genre.
Run your query to inspect the result.
Expected answer
- Columns: genre, rentals, revenue.
- Rows: genres with at least 3 rentals.
- Thriller leads with 6 rentals and 29.94 revenue.
Related
COUNT, SUM, AVG, MIN, MAX, GROUP BY, and HAVING.
COUNT, SUM, AVG, GROUP BY, and HAVING.
Practice aggregate reports, HAVING, and answer shape.
Avoid truncating fractional results.
Group or aggregate every selected column.
Nested SELECTs, IN, EXISTS, and correlation.