Number of Guests In each Resort in SQL

Question:

Number of Guests In each Resort

Management wants to display the resort details in which total guest stayed was 10 or less than. 

Write a query to display the resort Id, the total  count guests stayed as “Total Guest” in each resort. Total guest will be calculated by considering both adult and child count.  The result set should be in the ascending order of resort id.

Number of Guests In each Resort

Code:

Main.sql

select resortid, (sum(adultcount)+sum(childcount)) as "Total Guest"
from booking
group by resortid
having (sum(adultcount)+sum(childcount))<=10
order by resortid;

Recommended:

Leave a Comment

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