1. How to fetch all the duplicate records from the table.
2. How to fetch the second highest salary from the table.
Answer Posted / kunal gupta
These are the easiest and best queries and 100% tested.
1) 2nd highest salary
select top 1 sal from (Select top 2 sal from emp group by
sal order by sal desc) e order by sal
like wise you can find n highet salar(e.g 5th largest 6th
largest)
select top 1 sal from (Select top [n] sal from emp group by
sal order by sal desc) e order by sal
2) fetch all duplicated records from the table
e.g If table has three columns named 'col1', 'col2'
and 'col3'
select col1, col2, col3 from tbl group by col1, col2, col
having count(col1)>1
| Is This Answer Correct ? | 13 Yes | 3 No |
Post New Answer View All Answers
Due to some maintenance being done, the sql server on a failover cluster needs to be brought down. How do you bring the sql server down?
How to provide values to user defined function parameters?
Explain about service Broker functions?
How do I partition a table in sql server?
What is the standby server?
What is the difference between coalesce() & isnull()?
In one interview...interviewer ask me question pleas tell me sql server architecture.. can any body tell me the sql server architecture with digram
What is difference between rownum and rowid?
what is a live lock? : Sql server database administration
Mention the different authentication modes in sql server.
Explain the cursor lock types?
Explain the Ways to improve the performance of a sql azure database?
What is the datatype of rowid?
What is wide table?
How to execute stored procedure and set temp table in sql server?