The following will also work:
Code:
SELECT a.name, a.total_marks, count(*)
FROM student_table AS a INNER JOIN student_table AS b
ON a.total_marks <= b.total_marks
GROUP BY a.name, a.total_marks
HAVING count(*) < 6
ORDER BY 2 DESC
There is nothing specific to DB2 in this solution, though: this is standard SQL (which works with DB2 from at least version 7 on).
Starting version 8, though, there is indeed a more elegant (standard SQL) solution using OLAP functions.