![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
given this table: x * y -- *- 10 *a 20 *b 30 *c I want the best way to to map values [10,20) -> a * * * * * * * * * * * * * * * * * * *[20,30)] -> b * * * * * * * * * * * * * * * * * * *[30,inf) -> c Right now I'm using a query like: * * select y from foo * * *where x=(select max(x) from foo * * * * * * * *where x<=21); Is there a better way to do this? *Is there an analytic function that might help? Many TIA! Mark create table foo as select 10 as x ,'a' as y from dual union select 20,'b' from dual union select 30,'c' from dual; -- returns: a,b,b: select y from foo where x=(select max(x) from foo where x<=19); select y from foo where x=(select max(x) from foo where x<=20); select y from foo where x=(select max(x) from foo where x<=21); -- Mark Harrison Pixar Animation Studios |
![]() |
| Thread Tools | |
| Display Modes | |
| |