Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Answers were Sorted based on User's Feedback



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

Answer / arun kumar k s

select Distinct Top 2 Salary from EMP order by Salary desc

Is This Answer Correct ?    111 Yes 59 No

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

Answer / naren

select max(salary) as salary1 from employee where salary <
select max(salary) as salary2 from employee

Is This Answer Correct ?    27 Yes 16 No

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

Answer / 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

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

Answer / ranjeet kumar shrivastava

select * from tbl_htl_cntry e where 2>=(select
count(distinct salary) from tbl_htl_cntry where
e.salary<=salary)

it is aslo working syntax.
ranjeetvasu@rediffmail.com

Is This Answer Correct ?    10 Yes 3 No

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

Answer / suhail qaiser

select top 2 salary from emp order by salary desc

Is This Answer Correct ?    38 Yes 32 No

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

Answer / suhail qaiser

or if u want 2nd highest then write this query

select Top 1 salary from ( select top 2 salary from
emp_table order by salary desc)temptable order by salary
asc.

Is This Answer Correct ?    29 Yes 24 No

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

Answer / sums

Step1:
Create the "Salary" table,

Create table Salary
( Design_name varchar(20),
Basic_Sal int)

Step2:
Insert the values into "Salary" table,

Insert into Salary values('Office_Boy',4000)
Go
Insert into Salary values('Clerk',5000)
Go
Insert into Salary values('Head_Clerk',6000)
Go
Insert into Salary values('Accountant',7000)
Go
Insert into Salary values('Manager',8000)
Go
Insert into Salary values('PA',9000)
Go
Insert into Salary values('GM',10000)

Step3:
Write the Query aganist "Salary" table to find 'N'th
Maximum Basic Salary.

Query:

Select * from Salary s1 where (N =(select count(distinct
(s2.Basic_Sal)) from Salary s2
where s2.Basic_Sal>=s1.Basic_Sal))

N=1 --> Finds the first maximum Basic_sal
N=2 --> Finds the second maximum Basic_sal
N=3 --> Finds the Third maximum Basic_sal
.
.
.
N='N'--> Finds the 'N'th maximum Basic_sal

To find '2' maximum:

Select * from Salary s1 where (2=(select count(distinct
(s2.Basic_Sal)) from Salary s2
where s2.Basic_Sal>=s1.Basic_Sal))

Output:

Design_name Basic_sal

PA 9000

Is This Answer Correct ?    6 Yes 3 No

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

Answer / pari

select max(sal) from emp
where sal !=(select max(sal) from emp);

Is This Answer Correct ?    5 Yes 3 No

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

Answer / srinivas

select e1.sal from emp e1 where 2=(select count(distnct
(e2.sal) from emp e2 where e2.sal>=e1.sal)

Is This Answer Correct ?    33 Yes 32 No

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

Answer / saravanan p

select distinct top 2 salary from employee order by salary
desc

Is This Answer Correct ?    6 Yes 5 No

Post New Answer

More SQL Server Interview Questions

What is database dimension? : sql server analysis services, ssas

0 Answers  


How to swap the data of two columns in a table. both the columns containing varchar values.

9 Answers  


According to you what goes into making the best database administrator? : sql server database administration

0 Answers  


write an SQL query to list the employees who joined in the month of January?

0 Answers   Agilent, Amdocs,


How to find related tables in sql server?

0 Answers  


What is RAID and what are different types of RAID configurations?

8 Answers   Wipro,


What is a transaction and what are ACID properties?

14 Answers   Config Systems, IBM, TCS, Virtusa,


What is Covering Indexes? Plz explain with example

3 Answers  


How do I create a stored procedure in dbml?

0 Answers  


Is mysql the same as sql server?

0 Answers  


What is a trace frag? Where do we use it?

0 Answers  


In the below query i have performed the commit transaction statement but still the values after the save are not saved. Can you please let me know why are the statements after save are rolled back even after commiting the data. help me with the understanding declare @trans2 varchar(10)='transaction2' begin transaction @trans2 insert into emp values(100,'xy',600); save transaction @trans2 insert into emp values(200,'pq',700); insert into emp values(300,'pq',800); commit transaction @trans2 rollback tran @trans2

1 Answers   AllState,


Categories