Loading...

Top Content by Lifetime Value

A medium SQL interview practice problem on DataDriven. Write and execute real sql code with instant grading.

Domain
SQL
Difficulty
medium

Problem

Define each content item's lifetime value as the sum of watch_seconds from content_views across all viewers of that item. Ignore views with a null watch_seconds. Using DENSE_RANK over lifetime value descending, return content items in the top 3 ranks. If items tie at a rank, include all tied items. Show the content id, title, and lifetime value.

Practice This Problem

Solve this SQL problem with real code execution. DataDriven runs your SQL queries against a real database and grades it automatically.