Skip to content

bigfunctions > find_greater_value

find_greater_value

Signature

find_greater_value(arr, x)

Description

Return the offset (zero-based index) of the first value in arr where value >= x (or null if no value is greater than x).

Examples

1. When a strictly greater value exists in array

select bigfunctions.eu.find_greater_value([0, 20, 50, 80, 100], 25)
select bigfunctions.us.find_greater_value([0, 20, 50, 80, 100], 25)
select bigfunctions.europe_west1.find_greater_value([0, 20, 50, 80, 100], 25)
+--------+
| offset |
+--------+
| 2      |
+--------+

2. When an identical value exists in array

select bigfunctions.eu.find_greater_value([0, 20, 50, 80, 100], 20)
select bigfunctions.us.find_greater_value([0, 20, 50, 80, 100], 20)
select bigfunctions.europe_west1.find_greater_value([0, 20, 50, 80, 100], 20)
+--------+
| offset |
+--------+
| 1      |
+--------+

3. When a greater value does NOT exist in array

select bigfunctions.eu.find_greater_value([0, 20, 50, 80, 100], 110)
select bigfunctions.us.find_greater_value([0, 20, 50, 80, 100], 110)
select bigfunctions.europe_west1.find_greater_value([0, 20, 50, 80, 100], 110)
+--------+
| offset |
+--------+
| null   |
+--------+