Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select records with Maximum date group by address
Message
From
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:
00707131
Views:
25
This message has been marked as the solution to the initial question of the thread.
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)
Gordon de Rouyan
DC&G Consulting
Edmonton, Alberta
Email: derouyag@shaw.ca
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform