Complete the code to create an integer range from 1 to 10 (excluding 10).
SELECT int4range(1, [1]);
The int4range function creates a range of integers. The upper bound 10 is excluded by default, so int4range(1, 10) means from 1 up to but not including 10.
Complete the code to create a date range from January 1, 2023 to January 10, 2023 (excluding the end date).
SELECT daterange('2023-01-01', [1]);
The daterange function creates a date range. The end date is exclusive by default, so to include January 9, the end date should be January 10.
Fix the error in the code to check if the integer 5 is inside the range from 1 to 10.
SELECT 5 [1] int4range(1, 10);
The operator <@ checks if the left value is contained in the right range. So 5 <@ int4range(1, 10) returns true if 5 is inside the range.
Fill both blanks to create a range from 5 to 15 including 15.
SELECT int4range([1], [2], '];');
The int4range function takes lower and upper bounds. The '];' means the range includes the upper bound. To include 15, the upper bound must be 16 because the upper bound is exclusive by default unless specified.
Fill all three blanks to create a daterange from March 1, 2023 to March 31, 2023 including both dates.
SELECT daterange([1], [2], [3]);
The daterange function takes start date, end date, and bounds. To include both start and end dates, use bounds '[]'. The end date must be one day after March 31, which is April 1.