You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(student_id, subject, exam_date) is the primary key for this table.
16
+
Each row contains information about a student's score in a specific subject on a particular exam date. score is between 0 and 100 (inclusive).
17
+
Write a solution to find the students who have shown improvement. A student is considered to have shown improvement if they meet both of these conditions:
18
+
19
+
Have taken exams in the same subject on at least two different dates
20
+
Their latest score in that subject is higher than their first score
21
+
Return the result table ordered by student_id, subject in ascending order.
22
+
*/
23
+
24
+
WITH first_scores AS (
25
+
SELECT
26
+
student_id,
27
+
subject,
28
+
FIRST_VALUE(score) OVER (PARTITION BY student_id, subject ORDER BY exam_date ASC) AS first_score
29
+
FROM Scores
30
+
),
31
+
32
+
last_scores AS (
33
+
SELECT
34
+
student_id,
35
+
subject,
36
+
FIRST_VALUE(score) OVER (PARTITION BY student_id, subject ORDER BY exam_date DESC) AS latest_score
0 commit comments