MySQL Forums
Forum List  »  General

Re: Finding rank adn returning a range around said rank
Posted by: Peter Brawley
Date: July 06, 2016 08:53PM

> 1. For a given (School_Name, Class_Name, Student_Name) tell me their RANK based on Score.

select School_Name, Class_Name, Student_Name, avg(score)
from tbl
group by School_Name, Class_Name, Student_Name;

> 2. For a given range of sorted ROW_NUMBERS, return those records.

A fundamental feature of relational databases is that table row order is undefined; you need to specify the column values that are to determine rank order.



Edited 1 time(s). Last edit at 07/07/2016 10:07AM by Peter Brawley.

Options: ReplyQuote


Subject
Written By
Posted
Re: Finding rank adn returning a range around said rank
July 06, 2016 08:53PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.