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

From: Dario <drga59_at_hotmail.com>
Date: 3 Dec 2003 14:48:22 -0800
Message-ID: <e409f463.0312031448.2726f30a_at_posting.google.com>


Problem just calls for analytic functions:

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

Mark <mark_at_nowhere.com> wrote in message news:<95qdnTXq_YDFa1aiRVn-iQ_at_wideopenwest.com>...
> 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