Interview Query

Top 3 Users

Start Timer

0:00:00

Upvote
24
Downvote
Save question
Mark as completed
View comments (33)
Next question

Let’s say you work at a file-hosting website. You have information on user’s daily downloads in the download_facts table

Use the window function RANK to display the top three users by downloads each day. Order your data by date, and then by daily_rank

Example:

Input:

download_facts table

Column Type
user_id INTEGER
date DATE
downloads INTEGER

Output:

Column Type
daily_rank INTEGER
user_id INTEGER
date DATE
downloads INTEGER
.
.
.
.
.


Comments

Loading comments.