Window Function Practice #12

Window Function Practice #12

Hard Programming Interview DBMS 20 views
Explanation Complexity

Problem Statement

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.

Input / Output Format

Input Format
SQL tables are described in the question.
Output Format
Write the SQL query.

Example Solution (Public)

Programming Interview
SELECT user_id, score, created_at,
       DENSE_RANK() OVER(PARTITION BY CAST(created_at AS DATE) ORDER BY score DESC) AS rnk
FROM Scores;

Official Solution Code

SELECT user_id, score, created_at,
       DENSE_RANK() OVER(PARTITION BY CAST(created_at AS DATE) ORDER BY score DESC) AS rnk
FROM Scores;
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.