Bird
0
0

What result does this query produce?

medium📝 query result Q5 of 15
SQL - Advanced Query Patterns
What result does this query produce?
SELECT * FROM events WHERE start_date <= '2024-06-10' AND end_date >= '2024-06-05';
Given events:
1) 2024-06-01 to 2024-06-04
2) 2024-06-06 to 2024-06-12
3) 2024-06-08 to 2024-06-09
AEvents 1, 2, and 3
BEvents 2 and 3 only
CEvents 1 and 2 only
DEvent 2 only
Step-by-Step Solution
Solution:
  1. Step 1: Understand the date filter

    The query selects events overlapping the date range 2024-06-05 to 2024-06-10.
  2. Step 2: Check each event

    Event 1 ends before 2024-06-05, so excluded. Event 2 overlaps fully. Event 3 is within the range, so included.
  3. Final Answer:

    Events 2 and 3 only -> Option B
  4. Quick Check:

    Events overlapping given range = Events 2 and 3 only [OK]
Quick Trick: Check if event start ≤ range end and event end ≥ range start [OK]
Common Mistakes:
  • Including events that end before the range starts
  • Excluding events that start inside the range
  • Misreading the date comparisons

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes