View Single Post

   
  #3 (permalink)  
Old 02-24-2008, 06:09 AM
Jay
 
Posts: n/a
Default Re: SQL question - find rows surrounding criteria

>
> You can do this:
>
> --
> select id,tms,price from (
> select id, tms, price,
> row_number() over (order by case when delta >=0 then delta end)

rn1,
> row_number() over (order by case when delta <=0 then -delta end) rn2
> from (select id, tms, price, tms - to_date('1/2/04 18:00:00', 'mm/dd/yy
> hh24:mi:ss') delta from quote)
> ) where rn1=1 or rn2=1
>


Thanks VC, I'll have to look up the "over" clause

Jay


Reply With Quote