Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select records with Maximum date group by address
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00705983
Message ID:
00705986
Views:
21
If address is the same than what difference date makes?

>Hi everybody,
>
>I have a simple problem. I need to group records by address and select the records with maximum date (if we would have two or more same dates for the same address, I need all these records).
>
>My original SQL:
>
>select upper(...) as Address, max(date) as MaxDate, * from .. group by 1
>
>obviously produced incorrect results (but it took us a while to discover this problem).
>
>Here is the SQL I just tried:
>
>select upper(CCODE+TOWN+STREET+str(STNUM,4)+STNUMEXT+UNIT) as Address, * ;
>       from (m.tcTableName) fr where date = (select max(date) ;
>       from (m.tcTableName) se where ;
>       upper(fr.CCODE+fr.TOWN+fr.STREET+str(fr.STNUM,4)+fr.STNUMEXT+fr.UNIT) = ;
>       upper(se.CCODE+se.TOWN+se.STREET+str(se.STNUM,4)+se.STNUMEXT+se.UNIT)) ;
>       order by 1 into table (m.lcFile)
>
>but it gives me an error: SQL: Error correlating fields (Error 1801)
>
>Could you please tell me, how this SQL should be re-written?
>
>Thanks a lot in advance.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform