Generalize the query nearest value fxnality