Jump to content

how to retrieve second max salary without using subquery and limit in mysql?


suresh64633

Recommended Posts

Hi guys

I got the query

# OPTION ONE: To find 3rd highest

select * from salary e where
3 =(select count(distinct salary) from salary where e.salary<=salary)

 

 

# OPTION TWO: It find only 2nd highest.

SELECT max( p1.sal ) FROM jos_salary p1, jos_salary p2 WHERE p1.sal < p2.sal

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.