To find second largest salary in Employee table
Answer Posted / ram
select *from emp e where &n in(select count(distinct sal)
from emp m where e.sal<=m.sal);
which will ask's u like :
enter the value for n : 2 (enter 2)
gives u second highest.
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
How to execute the cursor queries with "open" statements?
What is difference between getdate and sysdatetime in sql server 2008?
How do you handle datasets larger than 50 gb?
What is the difference between row_number and dense_rank?
Why do we partition data?
What is normalization? Explain different forms of normalization?
what's the difference between delete table and truncate table commands? : Sql server database administration
Explain what are the restrictions while creating batches in sql server?
How to reaname table name without using sp_Rename in sql server..?
Do you know the cursor types?
what is the difference between Tabular and Matrix report?
How to create new table with "create table" statements?
How to rebuild the master database?
what stored procedure would you use to view lock information? : Sql server administration
How to delete existing triggers using "drop trigger"?