Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Help!Select latest date.
Am I missing something here? Seems pretty easy:
SELECT column1, column2, column3, date_column (etc.)
FROM table
WHERE date_column = (SELECT MAX( date_column) FROM table)
/
Gets 'THE' latest created record. I don't think this is exactly what you want, though. If you want to make sure that you get all rows from that DAY (if they were created manually then only one record will have the actual 'MAX' creation date, 'latest one on that day'), set the query to:
...
WHERE date_column >= (SELECT MAX( date_column) - 1 FROM table)
(gets all records created within 24 hours of the last one)
or
...
WHERE date_column >= (SELECT MAX( TRUNC( date_column)) FROM table)
(gets all records created on the same day as the last one)
Chris
In article <0324E65CE2ABD11195C10000F878B46339DD04_at_ntsv2.bwsc.org>,
"Prizant Lev A." <PrizantLA_at_BWSC.ORG> wrote:
> Hi,
>
> I'm trying to select a record or records from a recordset with the
> latest date.
> For example if there are 4 records with date fields:
> 01-MAR-1999
> 02-MAR-1999
> 05-MAR-1999
> 05-MAR-1999
> then I want to select all records where dates are '05-MAR-1999'.
>
> Thanks in advance!
>
>
-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Fri Mar 19 1999 - 17:44:52 CST
![]() |
![]() |