1. How to fetch all the duplicate records from the table.

2. How to fetch the second highest salary from the table.

Answer Posted / saradhi

How to fetch the second highest salary from the table.
SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP n salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary
where n > 1 (n is always greater than one)

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many database files are there in sql server 2000?what are they?

580


When should you use an instead of trigger?

554


What are date and time data types in ms sql server?

527


Do you know the cursor types?

618


Does the unique constraint create an index?

566






What is meant by datasource?

517


How to use clusters?

550


is it important for a database administrator to understand the operating system and file access? : Sql server administration

583


How to implement one-to-one, one-to-many and many-to-many relationships while designing tables?

583


How to get all stored procedures in sql server?

507


Explain the categories of stored procedure i.e. System stored procedure, local stored procedure, temporary stored procedure, extended stored procedure, remote stored procedure?

549


Define msdb database?

598


How many types of database relationship in sql server?

561


How to update multiple rows with one update statement in ms sql server?

634


What are information schema views?

551