Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select records with Maximum date group by address
Message
 
 
To
02/10/2002 17:59:03
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00705983
Message ID:
00707175
Views:
24
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform