what is syntex second or third highest salary.
thanks & Regards
Dhirendra sinha
Answer Posted / satish
select max(sal) from emp e1 where 1< (select count(distinct sal) from emp e2 where e1.sal <= e2.sal)
To make it generic if u want N'th highest salary;
select max(sal) from emp e1 where (N-1)< (select count(distinct sal) from emp e2 where e1.sal <= e2.sal)
And to get the N'th min sal :
select min(sal) from emp e1 where (N-1)< (select count(distinct sal) from emp e2 where e1.sal >= e2.sal)
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is GUID in sql server?
What is update_statistics command?
What is the meaning of lock escalation and why/how to stop this? : sql server database administration
What is the difference between web edition and business edition?
what are the basic functions for master, msdb, model, tempdb and resource system databases? : sql server database administration
Does partitioning help performance?
How do we Backup SQL Azure Data?
Can sql servers link to other servers like oracle?
How data can be copied from one table to another table?
What is a system database and what is a user database?
What is equi join with example?
How to delete duplicate records based on single column from a table?
Comment,Datatypes are unlimited
What is a not null constraint?
Explain concepts of analysis services?