Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Greatest value less than
I have a table which is essentially:
key level property --- ----- -------- a 100 foo b 250 foo c 500 foo d 100 bar e 250 bar f 500 bar
and, at runtime, I'll get a value, x, and a property, p. I need to find the key that corresponds to the largest value less than or equal to x and also to property p. I came up with the following query:
select key
from table
where level = (select max(level)
from table where level <= x and property = p) and property = p;
This seems awkward to me. Is there a more elegant solution? TIA.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Received on Thu Aug 05 1999 - 21:36:55 CDT
![]() |
![]() |