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: How do I get the most recent entries when ...

Re: How do I get the most recent entries when ...

From: Alan <alanshein_at_erols.com>
Date: Tue, 5 Feb 2002 16:42:13 -0500
Message-ID: <a3pjf7$19r7ar$1@ID-114862.news.dfncis.de>


SELECT DISTINCT id, field1, field2, max(date_entered) FROM this_homework_assignment
WHERE you_want_to_get_an_a = 'yes'
GROUP BY how_about_you_even_try_this_on_your_own_and_post_your_code_first

"D. Alvarado" <laredotornado_at_zipmail.com> wrote in message news:9fe1f2ad.0202051304.60f1ac2d_at_posting.google.com...
> I have a table like this:
>
> ID FIELD1 FIELD2 DATE_ENTERED
> -- ------ ------ ------------
> 1 xxx xxx 01-JAN-1997
> 2 xxx xxx 05-JAN-1998
> 1 xxx xxx 05-NOV-2001
> 2 xxx xxx 14-MAR-1999
> 1 xxx xxx 15-JAN-1996
>
> Assuming all DATE_ENTERED fields are unique (it is the primary key),
> how could I formulate a PL-SQL query that only selects the most
> recent entries per "ID" field. So, in this prmitive example, I'd want
> the query to return rows 3 and 4 because row 3 is the most recent
> entry for ID "1" and 4 is the most recent entry for ID "2".
>
> I'm using Oracle 8.1.7, if that matters.
>
> Thanks in advance, Dave A.
Received on Tue Feb 05 2002 - 15:42:13 CST

Original text of this message

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