write the query for find the top 2 highest salary in sql
server

Answer Posted / raja.p

Find The 4 Top Salary in a Company
----------------------------------

CREATE TABLE EMPLOYEE2 (NAME VARCHAR2(20), SALARY NUMBER) ;

CREATE TABLE employee2 (
name char(20),
salary float);
INSERT INTO employee2 VALUES (
'Raja',
10000);
INSERT INTO employee2 VALUES (
'Arithas',
10000);
INSERT INTO employee2 VALUES (
'Balaji',
12000);
INSERT INTO employee2 VALUES (
'Vairam',
13000);
INSERT INTO employee2 VALUES (
'Muthu Krishnan',
14000);
INSERT INTO employee2 VALUES (
'Muthu Kumar',
15000);
INSERT INTO employee2 VALUES (
'Ramesh',
9000);

select e.name,e.salary from Employee2 e where 4>(select
count(Distinct
d.salary)from employee2 d where d.salary>e.salary) order by
e.salary desc;

Is This Answer Correct ?    16 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between local and global temporary tables?

592


Explain iaas, paas and saas?

74


as a general practice, it is recommended to have dbo be the owner of all database objects however, in your database you find number of tables owned by a user other than dbo, how could you fix this? : Sql server administration

538


Explain try...catch with sql server?

602


What is the current pricing model of SQL Azure?

90






Call by value and call by reference in procedure and function, with NOCOPY.

844


What is an expensive query?

540


What is a self join in sql server?

602


Will the writetext statement activate a trigger?

573


what is a transaction? : Sql server database administration

473


What is the maximum rows in sql server table?

515


Why we need sql server?

563


What is serializable?

673


How to fetch the next row from a cursor with a "fetch" statement?

595


Tell about MOM Tool(Microsoft Operator Manager)?

1413