SQL SERVER DBA, Linux and Azure

How To Find The Highest Salary In SQL Server


Introduction:

In this blog we will discuss how to find the highest salary & the second highest salary..

Query to find the highest salary:

SELECT * FROM EMPLOYEE ORDER BY SALARY DESC  

SELECT MAX(SALARY) FROM EMPLOYEE   

Query to find second highest salary:

SELECT*FROM EMPLOYEE ORDER BY SALARY DESC  

SELECT MAX(SALARY) FROM EMPLOYEE  

WHERE SALARY<(SELECT MAX(SALARY) FROM EMPLOYEE) 

No comments:

Post a Comment