Bird
0
0

Which SQL condition correctly identifies overlapping periods between two date intervals (start_a, end_a) and (start_b, end_b)?

easy📝 Syntax Q3 of 15
SQL - Advanced Query Patterns
Which SQL condition correctly identifies overlapping periods between two date intervals (start_a, end_a) and (start_b, end_b)?
Astart_a = start_b AND end_a = end_b
Bstart_a >= end_b OR end_a <= start_b
Cstart_a < start_b AND end_a > end_b
Dstart_a <= end_b AND end_a >= start_b
Step-by-Step Solution
Solution:
  1. Step 1: Understand overlap logic

    Two date ranges overlap if the start of one is on or before the end of the other, and its end is on or after the start of the other.
  2. Step 2: Analyze each option

    start_a <= end_b AND end_a >= start_b uses the correct condition: start_a <= end_b AND end_a >= start_b. start_a >= end_b OR end_a <= start_b uses OR and reversed inequalities, which detects non-overlapping intervals. start_a < start_b AND end_a > end_b checks if one range is strictly inside the other, missing partial overlaps. start_a = start_b AND end_a = end_b checks for exact equality, which is too restrictive.
  3. Final Answer:

    start_a <= end_b AND end_a >= start_b -> Option D
  4. Quick Check:

    Overlap requires start before other's end and end after other's start [OK]
Quick Trick: Overlap if start ≤ other's end and end ≥ other's start [OK]
Common Mistakes:
  • Using OR instead of AND in the condition
  • Checking only if one range is fully inside the other
  • Testing for exact equality of start and end dates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes