5.8
Given a relation S(student,subject,marks), write a query to find the top 10 students by total marks, by using SQL ranking. Include all students tied for the final spot in the ranking, even if that results in more than 10 total students.
SELECT *
FROM (
SELECT student,total,RANK() OVER (ORDER BY (total) DESC) AS t_rank
FROM (
SELECT student, SUM(marks) AS total
FROM S
GROUP BY student
)
)WHERE t_rank <= 10