DEV Community

loading...

Discussion on: Challenge: Get Closest Number in an Array

Collapse
rhymes profile image
rhymes

hahaha thinking outside the box :D

Collapse
dmfay profile image
Dian Fay

I looked at it again just now and the row_number is redundant anyway...

SELECT unnest
FROM unnest(ARRAY[100,200,400,800,1600,3200,6400,128000])
ORDER BY abs(900 - unnest)
LIMIT 1;