Write a SQL query for second highest salary

Write a SQL query for second highest salary, Here is the query.

To fetch the second highest value from the database table there are several way.

Here I have used CO-RELATED Query concept and try to display the data.

SQL Query for | Second highest salary

--Query One
--Display 2nd Highest value from tblProduct
select * from tblproduct as p1 
where 2=
	(select count(*) from tblproduct as p2 
	where p2.ProductCost >= p1.ProductCost)

--Query 2 : TblProduct Information
select * from tblproduct

Select 3rd highest salary in SQL

In above query instead of 2=, you just need to write the code 3=, and you will get the output.

Leave a Comment