Interviews58 answers
Who to find 2nd lowest salary in employee table
58 Answers
Select Top 1 Salary as '2nd Minimum Salary' from (Select distinct top 2 salary from TableName order by Salary desc) a order by Salary asc
Sohan YadavPosted Nov 3, 2017, 6:40 AM EDT
Select Top 1 Salary as '2nd Minimum Salary' from (Select distinct top 2 salary from TableName order by Salary desc) a order by Salary asc
Sohan YadavPosted Nov 3, 2017, 6:40 AM EDT
Select Top 1 Salary as '2nd Minimum Salary' from (Select distinct top 2 salary from TableName order by Salary desc) a order by Salary asc
Sohan YadavPosted Nov 3, 2017, 6:39 AM EDT
Select max(sal) from salary where sal < (Select top 2 max(sal) from salary order by sal desc)
sushil kumarPosted Jul 8, 2017, 1:53 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:34 AM EDT
select MIN(Salary) from Employee
WHERE Salary <> (select MIN(Salary) from Employee )
Ashwani ChaudharyPosted Oct 2, 2016, 10:33 AM EDT
Select top 1 * from( select top 2 * from employees order by salary desc)t
Ashish SrivastavaPosted Dec 20, 2015, 6:53 AM EST
Select TOP 1 Salary as '2rd Lowest Salary'
from (SELECT DISTINCT TOP 2 Salary from Employee ORDER BY Salary ASC)
a ORDER BY Salary DESC
venkataramana reddyPosted Dec 2, 2015, 9:44 PM EST
SELECT MAX(SALARY) FROM (SELECT TOP 2 SALARY FROM EMPLOYEE ORDER BY SALARY ASC) Res
Pankaj Kumar ChoudharyPosted Aug 26, 2015, 9:17 AM EDT
select TOP 1 salary from(select distinct TOP 2 salary from employee order by salary asc) a order by salary desc
vinoth kumarPosted Aug 17, 2015, 11:03 PM EDT
select *
from (SELECT DENSE_RANK() over (order by total_price desc) as SNO , total_price FROM Sales) as dr
where SNO = 2
Suyambu KesavanPosted Jul 21, 2015, 3:52 AM EDT
Select TOP 1 Salary as '2rd Highest Salary' from (SELECT DISTINCT TOP 2 Salary from Employee ORDER BY Salary ASC) a ORDER BY Salary DESC
Sujeet SumanPosted Jul 19, 2015, 7:56 AM EDT
Select Top 1 EmployeeName,Salary from
(Select Top 2 EmployeeName,Salary From TblEmployee order by Salary desc) TblTempEmployee
order by Salary desc
Ankit ShuklaPosted Jul 8, 2015, 2:37 AM EDT
Select max(salary ) from table1 where salary not in (Select max(salary) from table1)
Junior KadelPosted May 14, 2015, 5:21 AM EDT
SELECT MIN(No)
FROM dbo.tbltemp2
WHERE No NOT IN ( SELECT DISTINCT TOP 1
No
FROM dbo.tbltemp2
ORDER BY No )
Posted Apr 14, 2015, 12:48 AM EDT
SQL Server 2008 R2 or earlier
SELECT SALARY
FROM(SELECT SALARY, ROW_NUMBER() OVER(ORDER BY SALARY ASC) AS ROWNUM
FROM SALARYTABLE) SAl
WHERE ROWNUM=2
SQL Server 2012 or Higher
Select Salary
From Table
Order By Salary
Offset 2 Rows
Fetch Next 1 Rows Only
Jigar TailorPosted Apr 13, 2015, 8:17 PM EDT
select salary from table
order by salary
offset 2 rows
fetch next 1 rows only
Satyam VermaPosted Apr 11, 2015, 8:05 PM EDT
select min(salary) from employee where salary<>(select min(salary) from employee);
Amar GavaliPosted Apr 7, 2015, 10:03 PM EDT
select min(salary) from employee where salary<>(select min(salary) from employee);
Amar GavaliPosted Apr 7, 2015, 10:03 PM EDT
http://dotnet-munesh.blogspot.in/2013/12/important-sql-query.html
Munesh SharmaPosted Mar 29, 2015, 8:10 PM EDT
SQL Queries in SQL Server, select MAX(SALARY) from (select top 2 * from employee) a
Munesh SharmaPosted Mar 29, 2015, 8:09 PM EDT
SELECT MIN(Salary) FROM Employee WHERE Salary NOT IN(SELECT MIN(Salary) FROM Employee)
SELECT MAX(SALARY) FROM (SELECT TOP 2 SALARY FROM EMPLOYEE ORDER BY SALARY ASC)
Akhil GargPosted Mar 28, 2015, 9:10 PM EDT
select min(amount)from Payment where
Amount not in (select distinct top 1 amount from Payment order by amount ASC )
for max
select max(amount)from Payment where
Amount not in (select distinct top 1 amount from Payment order by amount desc )
Shyam NarayanPosted Mar 21, 2015, 9:02 AM EDT
select Sal from Emp e1
where 1=(select Count(e2.sal) from Emp e2
where e2.sal>e1.sal)
Ganesh SarafPosted Mar 12, 2015, 10:31 PM EDT
SELECT SALARY FROM(
SELECT SALARY, ROW_NUMBER() OVER(ORDER BY SALARY ASC) AS ROWNUM FROM SALARYTABLE
) SAl WHERE ROWNUM=2
Abrar Ahmad AnsariPosted Mar 10, 2015, 3:04 AM EDT
As of SQL Server 2012 you can use:
SELECT Salary FROM Employees GROUP BY Salary ORDER BY Salary OFFSET 1 ROWS FETCH NEXT 1 ROWS ONLY
Guest UserPosted Mar 3, 2015, 5:44 AM EST
select MIN(sal) from emp where sal not in(select MIN(sal) from emp)
for min sal
raj kadamPosted Feb 27, 2015, 10:28 PM EST
select MAX(sal) from emp where sal not in(select MAX(sal) from Emp)
raj kadamPosted Feb 27, 2015, 10:20 PM EST
select MAX(sal) from emp where sal not in(select MAX(sal) from Emp)
raj kadamPosted Feb 27, 2015, 10:20 PM EST
select top 1 salary from(select distinct top 2 salary from emps order by Salary)a
order by a.salary desc
saravanagopi sPosted Feb 18, 2015, 10:07 PM EST
SELECT MAX(SALARY) FROM (SELECT TOP 2 SALARY FROM EMPLOYEE ORDER BY SALARY ASC) Res
sandeep kumarPosted Feb 7, 2015, 11:00 PM EST













