Bird
0
0

You wrote this query to find bookings fully inside June 2024:

medium📝 Debug Q14 of 15
PostgreSQL - Advanced Features
You wrote this query to find bookings fully inside June 2024:
SELECT * FROM bookings WHERE stay <@ daterange('2024-06-01', '2024-06-30');

But it returns no rows even though some bookings are inside June. What is the likely problem?
AThe <code>daterange</code> upper bound is exclusive by default, so '2024-06-30' is not included
BThe <code><@</code> operator checks for overlap, not containment
CThe <code>stay</code> column is not of type <code>daterange</code>
DThe query syntax is invalid and causes an error
Step-by-Step Solution
Solution:
  1. Step 1: Understand <@ operator meaning

    <@ means the left range is fully contained inside the right range.
  2. Step 2: Check daterange bounds behavior

    By default, daterange upper bound is exclusive, so '2024-06-30' is not included in the range. This excludes bookings on June 30.
  3. Final Answer:

    The daterange upper bound is exclusive by default, so '2024-06-30' is not included -> Option A
  4. Quick Check:

    Upper bound exclusive means end date not included [OK]
Quick Trick: Remember daterange upper bound is exclusive by default [OK]
Common Mistakes:
  • Confusing <@ with overlap operator
  • Assuming inclusive upper bound by default
  • Ignoring data type mismatch

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes