Use Logical AND/OR to Filter Hotel Data
Your operations team is reviewing hotel stays across New York state and needs to identify bookings that match specific patterns.
They’re interested in guests who either stay in New York City or have bookings of more than two nights.
To achieve this, you’ll combine multiple conditions using AND and OR — a common approach when refining datasets for reports or analysis.
Task
From the bookings table in the hotel_booking.sqlite database, return:
hotel_namecitystatenights
Only include rows where the state is 'NY' and either:
- the
cityis'New York', or - the number of
nightsis greater than 2.
How to solve it
Write a SQL query that applies all three filters.
Use AND to restrict the query to New York state, and use parentheses with OR to check for either a matching city or longer stay duration.
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help
Code Editor
Tables
Execution Result