Re: select next highest salary or last login date ...

From: Dario <>
Date: 3 Dec 2003 14:48:22 -0800
Message-ID: <>

Problem just calls for analytic functions:

select * from
 select e.*, rank() over (order by sal desc) rn  from emp e )
 where rn = 2

Mark <> wrote in message news:<>...
> good spam subject ;).
> anyway, i'm alittle stumped. i'm in need of putting together a query
> that gets the next highest salary ( select max ( sal ) - 1?, from an
> emp_sal type table. another example is if i have a login_history table,
> and i'm logged in, but i want to display the date of my previous login.
> if the login_history table has user_id and login_date which makes up
> the primary key, how can i get the most recent login (minus the most
> recent one?).
> the max function comes to mind and use of the rowid/rownum colums, but
> is there an easier, more obvious way to do this perhaps?
Received on Wed Dec 03 2003 - 23:48:22 CET

Original text of this message