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

if you encounter this kind of an error message, what you need to look into to solve this problem? : Sql server database administration

533


What are the differences between char and varchar in ms sql server?

585


What is the difference between update lock and exclusive lock?

502


What is a view in sql?

586


What is the difference between mysql and sql server?

479






What are the components of dbms?

540


What is the difference between sdf and mdf?

685


Where are sql server usernames and passwords stored in the sql server?

619


When would you use it?

590


What do you mean by data integrity?

608


How do you start single user mode in clustered installations?

530


What are the different types of collation sensitivity?

565


What is @@rowcount in sql?

566


How do I create an extended event in sql server?

499


How to configure odbc dsn with different port numbers?

570