Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: [SQL] how to avoid an inner join
Harald Fischer-Hohlweck wrote:
>
> Hi.
>
> Assume a table having a key Key and a column ValidFrom (ValidFrom is a
> date). All rows with a definite Key have different ValidFrom's. Can I
> get the row with the youngest ValidFrom in the past (i.e. the row that
> is valid actually) without an inner join? Something like
> select * from table
> where Key = value and ValidFrom = "max(ValidFrom) <= today";
select * from table
where Key = value
and ValidFrom = (SELECT max(ValidFrom) FROM table WHERE ValidFrom <= today";
Valery Yourinsky
-- Oracle8 Certified DBA Moscow, RussiaReceived on Mon Sep 17 2001 - 23:48:04 CDT