Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How do I find second highest value from a table?

user-image
Question added by Zaid Rabab'a , Technical Team Lead , ESKADENIA Software
Date Posted: 2012/12/30
Hazem Qannash
by Hazem Qannash , Technical Team Leader , Bayt.com

You can use this query: select distinct points from table order by points desc offset 1 limit 1; to return the second highest value from the table.

Deleted user
by Deleted user

I think this is the most straight forward solution..
SELECT MAX( col ) FROM table WHERE col < ( SELECT MAX( col ) FROM table )

Mostafa Shamout
by Mostafa Shamout , Web Designer , Freelance

SELECT salary_amount FROM (select salary2.*, rownum rnum from (select * from salary ORDER BY salary_amount DESC) salary2 where rownum = 2;

marwa khalaf
by marwa khalaf , .Net Developer , Sands National Academy

You can write as following : select min(ID) from Table limit 2

nithin koshy
by nithin koshy , Database administrator -INTERN , Syncron

SELECT TOP 2 FROM TABLE

ORDER BY <COLUMN_NAME> DESC;

More Questions Like This