Saturday, February 23, 2008

SQL-Server: Finding the Nth Highest & Nth Lowest in the SQL:

In the below way we can display any record, it can be fifth or 12th record from top. If we change the order by command to start in ascending order by changing the DESC to ASC ( or removing it , by default it is ASC ) we can get the lowest to highest and get the records from lowest ( last ) mark.

SELECT * FROM `student` where class='Six' ORDER BY mark desc LIMIT 0,1

No comments: