-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTOP Competitors
More file actions
20 lines (18 loc) · 805 Bytes
/
TOP Competitors
File metadata and controls
20 lines (18 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
Create a table in which contain the information about hacker id, submission id and challenge id.
In this table, only challenges ID that have full score is listed (compare the score in submission table with score in difficulty table.
From this table, select information about hacker id and name which have total challenge > 1
*/
WITH Table1 AS
(SELECT Hackers.hacker_id AS H1, name,
submission_id, Submissions.challenge_id AS C1
FROM Hackers
JOIN Submissions ON Hackers.hacker_id = Submissions.hacker_id
JOIN Challenges ON Submissions.challenge_id = Challenges.challenge_id
JOIN Difficulty ON Challenges.difficulty_level = Difficulty.difficulty_level
WHERE Submissions.score = Difficulty.score)
SELECT H1, name
FROM Table1
GROUP BY H1, name
HAVING count(C1)>1
ORDER BY count(C1) DESC, H1 ASC;