Range Functions
Range functions are used to define the upper and lower bounds of a range and determine whether a value is within the range.
lower(anyrange)
Description: Obtains the lower bound of a range. The function returns null if the range is empty or the lower bound is infinite.
Return type: Range's element type
Example:
1 2 3 4 5 | SELECT lower(numrange(1.1,2.2)) AS RESULT; result -------- 1.1 (1 row) |
upper(anyrange)
Description: Obtains the upper bound of a range. The function returns null if the range is empty or the upper bound is infinite.
Return type: Range's element type
Example:
1 2 3 4 5 | SELECT upper(numrange(1.1,2.2)) AS RESULT; result -------- 2.2 (1 row) |
isempty(anyrange)
Description: Determines whether a range is empty.
Return type: Boolean
Example:
1 2 3 4 5 | SELECT isempty(numrange(1.1,2.2)) AS RESULT; result -------- f (1 row) |
lower_inc(anyrange)
Description: Determines whether the lower bound of a range is included.
Return type: Boolean
Example:
1 2 3 4 5 | SELECT lower_inc(numrange(1.1,2.2)) AS RESULT; result -------- t (1 row) |
upper_inc(anyrange)
Description: Determines whether the upper bound of a range is included.
Return type: Boolean
Example:
numrange(1.1, 2.2) uses the [1.1, 2.2) format by default. The upper bound (2.2) is not included by default. Therefore, false is returned.
1 2 3 4 5 | SELECT upper_inc(numrange(1.1,2.2)) AS RESULT; result -------- f (1 row) |
lower_inf(anyrange)
Description: Determines whether the lower bound of a range is infinite.
Return type: Boolean
Example:
1 2 3 4 5 | SELECT lower_inf('(,)'::daterange) AS RESULT; result -------- t (1 row) |
upper_inf(anyrange)
Description: Determines whether the upper bound of a range is infinite.
Return type: Boolean
Example:
1 2 3 4 5 | SELECT upper_inf('(,)'::daterange) AS RESULT; result -------- t (1 row) |
The lower_inc, upper_inc, lower_inf, and upper_inf functions all return false for an empty range.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot