58
Reply

Who to find 2nd lowest salary in employee table

sandeep kumar

sandeep kumar

9y
5.8k
0
Reply

    select salary from table order by salary offset 2 rows fetch next 1 rows only

    SELECT SALARY FROM(SELECT SALARY, ROW_NUMBER() OVER(ORDER BY SALARY ASC) AS ROWNUM FROM SALARYTABLE ) SAl WHERE ROWNUM=2

    select top 1 salary from(select distinct top 2 salary from emps order by Salary)a order by a.salary desc

    SELECT MAX(SALARY) FROM (SELECT TOP 2 SALARY FROM EMPLOYEE ORDER BY SALARY ASC) Res

    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

    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

    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

    Select max(sal) from salary where sal < (Select top 2 max(sal) from salary order by sal desc)

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    select MIN(Salary) from Employee WHERE Salary <> (select MIN(Salary) from Employee )

    Select top 1 * from( select top 2 * from employees order by salary desc)t

    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

    SELECT MAX(SALARY) FROM (SELECT TOP 2 SALARY FROM EMPLOYEE ORDER BY SALARY ASC) Res

    select TOP 1 salary from(select distinct TOP 2 salary from employee order by salary asc) a order by salary desc

    select *from (SELECT DENSE_RANK() over (order by total_price desc) as SNO , total_price FROM Sales) as dr where SNO = 2

    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

    Select Top 1 EmployeeName,Salary from (Select Top 2 EmployeeName,Salary From TblEmployee order by Salary desc) TblTempEmployee order by Salary desc

    Select max(salary ) from table1 where salary not in (Select max(salary) from table1)

    SELECT MIN(No) FROM dbo.tbltemp2 WHERE No NOT IN ( SELECT DISTINCT TOP 1NoFROM dbo.tbltemp2ORDER BY No )

    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=2SQL Server 2012 or Higher Select Salary From Table Order By Salary Offset 2 Rows Fetch Next 1 Rows Only

    select min(salary) from employee where salary<>(select min(salary) from employee);

    select min(salary) from employee where salary<>(select min(salary) from employee);

    http://dotnet-munesh.blogspot.in/2013/12/important-sql-query.html

    SQL Queries in SQL Server, select MAX(SALARY) from (select top 2 * from employee) a

    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)

    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 )

    select Sal from Emp e1 where 1=(select Count(e2.sal) from Emp e2where e2.sal>e1.sal)

    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

    select MIN(sal) from emp where sal not in(select MIN(sal) from emp) for min sal

    select MAX(sal) from emp where sal not in(select MAX(sal) from Emp)

    select MAX(sal) from emp where sal not in(select MAX(sal) from Emp)