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
What is the advantage of sql server?
Do you know what is difference between index seek vs. Index scan?
Which tcl commands are available on the sql server?
Explain cursor as data base object?
How to call a function from a stored procedure in SQL Server ?
What is log shipping? Can we do logshipping with SQL Server 7.0 - Logshipping is a new feature of SQL Server 2000. We should have two SQL Server - Enterprise Editions. From Enterprise Manager we can configure the logshipping. In logshipping the transactional log file from one server is automatically updated into the backup database on the other server. If one server fails, the other server will have the same db and we can use this as the DR (disaster recovery) plan.
What is the purpose of update statistics and scope_identity() function?
what do you understand by change data capture?
How to create an identity column?
What is sql server management studio? : sql server management studio
What are the functions in sql server?
What is #table in sql server?
What do you understand by user-defined function in the sql server?
How many types of built in functions are there in sql server 2012?
Do you know concepts and capabilities of sql server?