Fetch second highest cabin cost in SQL

Question:

Fetch second highest cabin cost

Write a query to display the second highest cabin cost rate. Give alias name as SECOND_MAX. 

Fetch second highest cabin cost

Code:

Main.sql

select distinct rate as SECOND_MAX
from cabincost
where rate=(select max(rate) from cabincost where rate< (select max(rate) from cabincost));

Recommended:

Leave a Comment

Your email address will not be published. Required fields are marked *