LARGE lets you find the nth largest value in an array. SMALL lets you find the nth smallest value in an array.
I want to do something like select SMALL([col1, col2, col3, 2], 2), LARGE([col1, col2, col3, 5], 2) from table1;
I am not looking for the GREATEST and LEAST FUNCTIONS. I want to find the nth smallest/largest values and not the smallest/largest values.
sort()
function instead of unnesting and aggregating in the function, e.g:(sort(array[3,5,1,2]))[2]
that will be a lot faster.Numeric
. Is there a NumericArray sort of thing? I look at the solution and worry about performance for large number of rows.