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

Home -> Community -> Usenet -> c.d.o.server -> Re: [SQL] how to avoid an inner join

Re: [SQL] how to avoid an inner join

From: Valery Yourinsky <vsu_at_bill.mts.ru>
Date: Tue, 18 Sep 2001 08:48:04 +0400
Message-ID: <3BA6D204.DA600C7C@bill.mts.ru>


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, Russia
Received on Mon Sep 17 2001 - 23:48:04 CDT

Original text of this message

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