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
How do you drop an index?
Your sql server is running out of disk space. You notice that there are several large files with ldf extensions what are these files?
What are the drawbacks of reporting in ssrs?
Explain an incremental backup?
Can a trigger be created on a view?
What do you mean by normalisation?
Can truncate be rolled back?
What are the built in functions in sql server?
Why we use functions in sql server?
What is the difference between insensitive and scroll cursor?
What is the difference between deallocate cursor and close cursor?
What is CTE in SQL
What are sql server procedures?
What is a linked server in sql server?
Explain what you mean by 3 tier architecture.