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 one of two key patterns.
They're interested in guests either staying in New York City, or booking a stay of more than two nights. You'll help them generate this filtered list.
To do this, you'll combine multiple conditions using both AND
and OR
in your SQL query. This is a common scenario when refining data for analysis or reporting.
What to Show
From the bookings
table in the hotel_booking.sqlite
database, return:
hotel_name
city
state
nights
Only include rows where the state
is 'NY'
and either:
- the
city
is'New York'
, or - the number of
nights
is greater than 2.
Instructions
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