Top 3 Users
Start Timer
0:00:00
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 |
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments