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

How to create “dependant” parameter “make, model, year”

105


How to create a scrollable cursor with the scroll option?

671


Where do we use trace frag?

732


Tell me what are the advantages of using stored procedures?

743


Tell me in brief how sql server enhances scalability of the database system?

714






What is the difference between drop table and truncate table?

657


Explain the dirty pages?

755


Explain the rules for designing files and file groups in sql server?

710


How to change the name of a database user?

735


How do I find the port number for sql server?

689


What is the difference between dbcc indexdefrag and dbcc reindex?

708


What is the data type of time?

689


How do I install sql server?

623


what stored procedure can you use to display the current processes? : Sql server administration

718


Explain foreign key in sql server?

751