Restaurant Open

ASKED IN INTERVIEW
2pts
Door Dash

Problem Statement

DoorDash needs to provide users with a real-time list of restaurants that are ready to accept orders. A restaurant is considered open if the current_time is greater than or equal to its open_time and strictly less than its close_time.

Write an SQL query to find all restaurants that are open at 18:30:00 (6:30 PM).

Rules:

  • The input current_time is 18:30:00.
  • A restaurant is open if: open_time <= current_time < close_time.
  • Output columns: restaurant_name, open_time, close_time.
  • Sort the results in ascending order by restaurant_name.

Table Schema:

  • Restaurants: restaurant_id, restaurant_name, cuisine_type, open_time (TIME), close_time (TIME).
Tests your understanding of
Basic SQL, DateTime, Filtering and Logical Operators

Input Tables

Restaurants
restaurant_name(VARCHAR)open_time(TIME)close_time(TIME)
Burger Kingundefined22:00:00
Sushi Zen11:00:0021:00:00
Late Night Pizza18:00:0002:00:00
Morning Bagels06:00:0014:00:00
Taco Bell10:00:0023:00:00
Pasta Palace12:00:0018:30:00

Expected Output

restaurant_name(VARCHAR)open_time(TIME)close_time(TIME)
Sushi Zen11:00:0021:00:00
Taco Bell10:00:0023:00:00

Tags

EasyASKED IN INTERVIEWBasic SQLDateTimeFilteringLogical Operators
10 min
79%

Hints