Window Function Practice #30
Programming Interview
Hard
4 views
Problem Description
Table: Scores(user_id, score, created_at). Return each row with the rank of score within the same day.
Input Format
SQL tables are described in the question.
Output Format
Write the SQL query.
Official Solution
SELECT user_id, score, created_at,
DENSE_RANK() OVER(PARTITION BY CAST(created_at AS DATE) ORDER BY score DESC) AS rnk
FROM Scores;
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!