Tutorial :Select n largest values from a table



Question:

How can I select the 100 largest rows in a table based on a column 'score'?

I can find the largest score in the 'score' column with:

SELECT max(score) FROM mTable  

And then obtain that row(s):

SELECT * FROM mTable WHERE score=largestScore  

But how would I wrap this up and obtain the following 99 lower scored rows?

Thanks.


Solution:1

Use:

SELECT t.*  FROM MTABLE t  ORDER BY t.score DESC  LIMIT 100  


Solution:2

Formatted:

Select *    from mtable   order by score desc    limit 100  


Solution:3

SELECT columnList  FROM mTable  ORDER BY score DESC  LIMIT 100  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »