LogiQuest

523. Rank Students in Class

HardWindow FunctionsDENSE_RANK

For students with marks, return class, name, total score as total and their dense rank within the class by total as class_rank. Order by class, then class_rank, then name.

students

idnameclasscitydob
1Arun10AChennai2010-05-14
2Bala10AMadurai2010-08-02
3Charu10BChennai2009-12-25
4Deepa10BCoimbatore2010-03-30
5Ezhil10AChennai2010-11-11
6Farah10CNULL2010-01-19

subjects

idtitlemax_marks
1Maths100
2Science100
3English100
4Tamil100

marks

student_idsubject_idscore
1195
1288
1376
2167
2272
2381
3199
3294
3390
4145
4258
4362
5188
5291
5385
1490
3485

Your query runs on a fresh copy of these tables (SQLite). Column names in your result do not need to match.

Loading the MyLoginn IDE…