Hi
we are a problem to finding the third hieghest salary in a table
How we can find the second, third hieghest salary in a table?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Jan 19, 2012, 4:51 AM EST
Try this...
For 2nd highest salary here n=2
select distinct(salary) from employee A where 2=(select count(distinct(salary)) from employee B where A.salary<=B.salary)
For 3rd highest salary here n=3
select distinct(salary) from employee A where 3=(select count(distinct(salary)) from employee B where A.salary<=B.salary)
Thanks