MySql queries to find highest, second highest etc. values

If we have a table 'account' with fields 'accountid' and 'balance',



1. Query to find highest balance from 'account' is:

 select balance from account order by balance desc limit 0,1;


2.  Query to find second highest balance from 'account' is:
  
select balance from account order by balance desc limit 1,1;
 

3.  Query to find third highest balance from 'account' is:

select balance from account order by balance desc limit 2,1;


    


Comments

Popular posts from this blog

how to add new line in google form questions | Fix for next line issue in google form questions

How to add new line in dropdown type question in google forms