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...


How to find the second largest salary in the emp database and
also How to find 3rd,4th and so on ........ in the emp database

plz mail the answer @ mak2786@gmail.com

Answers were Sorted based on User's Feedback



How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / yogesh

A little correction:

sol2> select salary from emp order by salary desc limit 1,1;

select salary from emp order by salary desc limit n-1,1;

Is This Answer Correct ?    1 Yes 1 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / riyazkhan

select Sal from Employee where Sal != (select max(Sal) from Employee) Order By Sal desc

Is This Answer Correct ?    1 Yes 1 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / ranjith

Select Max(Salary) from emp_database where Salary < (Select
Max(Salary) from emp_database)

Is This Answer Correct ?    0 Yes 0 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / veerdhawal

mysql> select max(sal) from emp where sal not in (select
max(sal) from emp);
+----------+
| max(sal) |
+----------+
| 30000 |
+----------+
1 row in set (0.01 sec)

Is This Answer Correct ?    1 Yes 1 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / ravi kumar

SELECT MIN(sal) FROM Emp WHERE sal in
(SELECT TOP 2 DISTINCT sal from Emp ORDER BY DESC)

Is This Answer Correct ?    0 Yes 0 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / harsha

select * from my_table1 where sal not in (select max(sal)
from my_table1) order by Sal desc

Is This Answer Correct ?    0 Yes 0 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / bobby

select p.emp_id,p.name,p.salary from
( select emp_id,name,salary,dense_rank()over( order by
salary desc)rank
from empTable )p
where rank=2

Is This Answer Correct ?    1 Yes 2 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / sandee saxena

-- Create table #temp
-- (
-- Emp_id int identity(1,1),
-- Emp_Name varchar (100) ,
-- Emp_Salary int
-- )

--
-- Insert into #Temp (Emp_Name, Emp_Salary) values
('kunal', '2000')
-- Insert into #Temp (Emp_Name, Emp_Salary) values
('aditya', '5000')
-- Insert into #Temp (Emp_Name, Emp_Salary) values
('abhishek', '6000')
-- Insert into #Temp (Emp_Name, Emp_Salary) values
('kailash', '5000')
-- Insert into #Temp (Emp_Name, Emp_Salary) values
('rohit', '8000')
-- Insert into #Temp (Emp_Name, Emp_Salary) values
('rakesh', '3000')

Select a.* From #temp a,
(Select Max(a.Emp_salary)Emp_Salary From #temp a,
(Select Max(x.Emp_salary)Emp_Salary From #temp a,
(Select a.* From #temp a,(Select Max (Emp_Salary)Emp_Salary
From #Temp) b
Where a.Emp_Salary < b.Emp_Salary ) x ) y
where a.Emp_Salary < y.Emp_Salary)Z
where a.Emp_Salary = z.Emp_Salary

Is This Answer Correct ?    0 Yes 1 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / sarat

TO FIND THE Nth HIGHEST SAL IN EMP TABLE

SELECT MIN (salary) as NthSalary FROM emptable WHERE
salary IN ( SELECT DISCINCT TOP N salary FROM emptable
ORDER BY salary DESC )

Is This Answer Correct ?    3 Yes 4 No

How to find the second largest salary in the emp database and also How to find 3rd,4th and so on ....

Answer / g

TO FIND THE 3rd,

select max(sal) from emptable where salary not in(select
distinct top 2 sal from emptable)

TO FIND THE 4th,

select max(sal) from emptable where salary not in(select
distinct top 3 sal from emptable)

TO FIND THE 5th,

select max(sal) from emptable where salary not in(select
distinct top 4 sal from emptable)

keep change top value...

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More SQL Server Interview Questions

what is normalization? what is denormalization?

9 Answers   Satyam,


What does COMMIT command do?

0 Answers   Amdocs,


1.can we set the more than 1 primary keys for a table? 2.please give me the difference between Cluster Index and non-Clustered Index 3.can we use query like this "Select * from Table1,Table2;"

8 Answers  


PC(code, model, speed, ram, hd, cd, price) Find the hard drive sizes that are equal among two or more PCs.

6 Answers   APX,


What is the name of the Database which IBM mainframe uses?

0 Answers   Wipro,


When would you use sql joins?

0 Answers  


can you any body tell me while running BCP Out in instance in sql server 2000 is getting error. Error = [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.?

1 Answers  


Normalization and denormalization

3 Answers   Wipro,


How to query multiple tables jointly?

0 Answers  


How to add a new dsn with the odbc driver for sql server?

0 Answers  


What is Trace flag?

1 Answers   Wipro,


I applied Transactional with updatable subscriptions replication on 2 tables now i want to delete those 2 tables but i cannot delete those tables as replication is running how can i stop replication for those 2 tables(but i don't want to delete those replicated tables but i need to stop the replication) how can i do that

0 Answers  


Categories