Query that ranks students order by marks and give the position of student even when there are students with equal marks
SELECT t1.id, mark,
(SELECT COUNT(*) FROM marktable t2 WHERE t2.mark &gt; t1.mark) +1
AS rnk
FROM marktable t1 order by rnk;


SQLFIDDLE