bigfunctions > find_lower_value
find_lower_value¶
Signature
find_lower_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 lower than x
).
Examples
1. When a strictly lower value
exists in array
select bigfunctions.eu.find_lower_value([5, 4, 3, 100], 3.5)
select bigfunctions.us.find_lower_value([5, 4, 3, 100], 3.5)
select bigfunctions.europe_west1.find_lower_value([5, 4, 3, 100], 3.5)
+--------+
| offset |
+--------+
| 2 |
+--------+
2. When an identical value
exists in array
select bigfunctions.eu.find_lower_value([5, 4, 3, 100], 4)
select bigfunctions.us.find_lower_value([5, 4, 3, 100], 4)
select bigfunctions.europe_west1.find_lower_value([5, 4, 3, 100], 4)
+--------+
| offset |
+--------+
| 1 |
+--------+
3. When a lower value
does NOT exist in array
select bigfunctions.eu.find_lower_value([5, 4, 3, 100], 2)
select bigfunctions.us.find_lower_value([5, 4, 3, 100], 2)
select bigfunctions.europe_west1.find_lower_value([5, 4, 3, 100], 2)
+--------+
| offset |
+--------+
| null |
+--------+