Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select records with Maximum date group by address
Message
 
 
À
02/10/2002 17:59:03
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00705983
Message ID:
00707175
Vues:
26
>One more try... using your SQL statement
>
>I re-read Sergey's... mine is slightly different where I use the MAX() of the combination of address and date. By useing just the date, you return similar results as SELECT *, Max(DATE) which has proven to be incorrect.
>
>By selecting the max of both the address and the date, you basically fuse the two together before the MAX() is performed. If you have the same address records with two different dates, only the MAX(DATE) will come across. Also as you requested, if you have the same address and same date, both will come across. Of course SELECT DISTINCT would filter those out too if you want.
>
>
>I did forget one thing though, the inner Group By clause.
>
>select upper(CCODE+TOWN+STREET+str(STNUM,4)+STNUMEXT+UNIT) as Address, * ;
> from address where upper(CCODE+TOWN+STREET+str(STNUM,4)+STNUMEXT+UNIT) + TRANSFORM(date) IN ;
> (select MAX(upper(CCODE+TOWN+STREET+str(STNUM,4)+STNUMEXT+UNIT) + TRANSFORM(date)) ;
> from address
> GROUP BY CCODE, TOWN, STREET, STNUM, STNUMEXT, UNIT) ;
> order by 1 into table (m.lcFile)

I think, this would work. Only instead of TRANSFORM I would use DTOS (Actually, it doesn't matter).

I'm not sure, what would be faster: 2 SQLs or this one. I need to test.

Thanks a lot for the help.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform