Bird
0
0

Given the table bookings with a daterange column stay, what does this query return?

medium📝 query result Q13 of 15
PostgreSQL - Advanced Features
Given the table bookings with a daterange column stay, what does this query return?
SELECT * FROM bookings WHERE stay && daterange('2024-06-01', '2024-06-10');
ARows where stay starts exactly on June 1, 2024
BRows where stay is completely inside June 1 to June 10, 2024
CRows where stay ends before June 10, 2024
DRows where stay overlaps with June 1 to June 10, 2024
Step-by-Step Solution
Solution:
  1. Step 1: Understand the operator && for ranges

    The && operator checks if two ranges overlap at all.
  2. Step 2: Analyze the query condition

    The query selects rows where the stay range overlaps with the range from June 1 to June 10, 2024.
  3. Final Answer:

    Rows where stay overlaps with June 1 to June 10, 2024 -> Option D
  4. Quick Check:

    Range overlap operator && means any overlap [OK]
Quick Trick: && means any overlap between ranges [OK]
Common Mistakes:
  • Thinking && means fully inside
  • Confusing overlap with exact start or end match
  • Assuming it filters only before or after dates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes