tcTableName = getfile('dbf') lcFile = justfname(m.tcTableName)+"TempTest" select upper(CCODE+TOWN+STREET+str(STNUM,4)+STNUMEXT+UNIT) ; as Address, max(date) as MaxDate from (m.tcTableName) ; group by 1 into cursor curTemp select upper(CCODE+TOWN+STREET+str(STNUM,4)+STNUMEXT+UNIT) ; as Address, * from (m.tcTableName) tbl ; inner join curTemp on ; upper(tbl.CCODE+tbl.TOWN+tbl.STREET+str(tbl.STNUM,4)+tbl.STNUMEXT+tbl.UNIT) = ; curTemp.Address and tbl.Date = curTemp.MaxDate *!* 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 I'm not sure, I get it right... I could not figure out to do it in one SQL, though it's not a goal (if it could not be done in 1 select, I can use multiple)
>>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)>>