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: Michael Ringbo <mhr_at_NOSPAMramboll.dk>
Date: Mon, 28 Jun 1999 10:28:24 +0200
Message-ID: <37773228.A87611F6@NOSPAMramboll.dk>


Hi

I go for this one:

Select m.name, m.rented, m.date
from mytable m
where not exists (select null
from mytable b
where b.name = a.name
and b.date > a.date);

Be aware that if the data possibly contains more than 1 row for a name on the same (truncated?) date, then you will get all these rows in your output. This can be avoiding with "Select distinct(m.name, m.rented, m.date)...."

Hope this helps

Regards, Michael Ringbo

tan 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.
>
> 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.
Received on Mon Jun 28 1999 - 03:28:24 CDT

Original text of this message

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