Subject Re: [firebird-support] query returning the most recent date
Author Alexandre Benson Smith
Maurizio P. wrote:
> hi ,
> i ask an help for a situation like this :
>
> in a table PRICELIST i have the following situation :
>
> COD DATE PRICE
> A1 01.01.2007 100
> A1 05.05.2007 220
> B1 02.02.2007 110
> B1 08.08.2007 130
> A1 09.09.2007 160
>
> i need a query which returns only then COD and
> the PRICE with the most recent DATE :
>
> COD DATE PRICE
> A1 09.09.2007 160
> B1 08.08.2007 130
>
> thanks
> Mauro
>


select
*
from
PriceList P
where
not exists (select 1 from PriceList P2 where P2.Cod = P.Cod and
P2.Dat2 > P.Date)

see you !

--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br