SQL QuestSQL Interview Questions › Conditional Logic

Rounded Revenue: Top 10 from 2015+

EasyFreeQuerying BasicsConditional Logic

A box-office summary report wants integer-rounded revenue for the 10 highest-grossing films released in 2015 or later — no decimals cluttering the row.

Show title, year, and ROUND(revenue_millions, 0) AS revenue_rounded. Filter to year >= 2015. Order by revenue_rounded descending. Limit 10.

ROUND(value, decimals) rounds to N decimal places. ROUND(x, 0) rounds to the nearest integer. ROUND(x, -2) rounds to the nearest hundred. SQLite, Postgres, and MySQL all support this signature.

Solve it in the browser editor →

Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".

Schema

movies

idtitleyeargenreratingvotesrevenue_millionsruntimedirector
1Guardians of the Galaxy2014Action8.1757074333.13121James Gunn
2Prometheus2012Adventure7485820126.46124Ridley Scott
3Split2016Horror7.3157606138.12117M. Night Shyamalan

Expected output: Toy Story 4 | 2019 | 1073

Hint

The hint for this one spells out most of the query, so it stays in the editor. Reach for SELECT, ROUND, WHERE, and open the hint there if you stall.

Concepts

SELECT ROUND WHERE ORDER BY LIMIT Expressions

Practise the topic: SQL practice questions · CASE WHEN practice

Related questions

Calculated ColumnsEasy · FreeComp Tier LabelsEasy · FreeMembership Display LabelsEasy · FreeAsset Tier ClassificationEasy · FreeBuilding Age TierEasy · FreeTool Wear Stress TierEasy · Free

Where would this cost you points in an interview?

Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.

Take the readiness test