Lecture

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_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.

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.

sqlQuiz
?

Lecture

AI Tutor

Design

Upload

Notes

Favorites

Help

Code Editor

Run
Generate

Tables

Execution Result