Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL question.

Re: SQL question.

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Sun, 27 Jun 1999 02:26:08 GMT
Message-ID: <37798b62.22817750@newshost.us.oracle.com>


A copy of this was sent to tan <tunrog_at_yahoo.com> (if that email address didn't require changing) On Sun, 27 Jun 1999 01:54:07 GMT, you wrote:

> I have a simple question, suppose I have a table below:
>
> NAME RENTED DATE
>
> Bob A 03/29/98
> Bob A 05/19/99
> Joe D 12/19/98
> Barb E 03/09/99
> Barb C 06/19/99
> Barb E 09/05/98
>
>
> How do I just retrieve the most recent rows (by date)
> for each person? Thanks.
>

select *
  from t
 where ( name, date ) in ( select name, max(date)

                             from t
                            group by name )
/

>ie.
> NAME RENTED DATE
>
> Bob A 05/19/99
> Joe D 12/19/98
> Barb C 06/19/99
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.

--
See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st  

Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Sat Jun 26 1999 - 21:26:08 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US