* Turn on SQL progress bar set talk on set talk window noshow select DsID, rcode, town, max(ExtrYear+ExtrWeek) as PriorWeek, ; Record_fm, Record_To ; from FilingDate group by 1 ; having !empty(Record_Fm) ; where ExtrYear+ExtrWeek < m.lcIssue ; and State = m.lcState ; into cursor curTemps select DsID, rcode, town, max(ExtrYear+ExtrWeek) as PriorWeek, ; LandCt_fm, LandCt_To ; from FilingDate group by 1 ; having !empty(LandCt_Fm) ; where ExtrYear+ExtrWeek < m.lcIssue ; and State = m.lcState ; into cursor curLCTemps select fd1.DsID, fd1.rcode, fd1.town, ; fd1.Record_fm, fd1.Record_to, ; fd1.LandCt_fm, fd1.LandCt_to, ; nvl(curTemps.Record_fm,{}) as PriorRec_fm, ; nvl(curTemps.Record_to,{}) as PriorRec_To, ; nvl(curLCTemps.LandCt_fm,{}) as PriorLC_fm, ; nvl(curLCTemps.LandCt_to,{}) as PriorLC_to ; from FilingDate fd1 left join curTemps ; on fd1.DsID=curTemps.DsID ; left join curLCTemps ; on fd1.DsID=curLCTemps.DsID ; where fd1.State+fd1.ExtrYear+fd1.ExtrWeek = m.lcCurrentStWeek ; order by 2,3 ; into cursor TmpDates *--- Turn off SQL progress bar. set talk off>Wouldn't :
>>select rcode, town, max(ExtrYear+ExtrWeek) as PriorWeek ; >> from FilingDates group by 1,2 ; >> having !empty(Record_Fm) ; >> where ExtrYear+ExtrWeek < CurrentWeek into cursor curTemp >> >>Select Record_Fm as Prior_Fm,... from FilingDates inner join curTemp...>>
>>> select fd1.DsID, fd1.rcode, fd1.town, ; >>> fd1.Record_fm, fd1.Record_to, ; >>> fd1.LandCt_fm, fd1.LandCt_to, ; >>> nvl(fd2.Record_fm,{}) as PriorRec_fm, ; >>> nvl(fd2.Record_to,{}) as PriorRec_To, ; >>> nvl(fd2.LandCt_fm,{}) as PriorLC_fm, ; >>> nvl(fd2.LandCt_to,{}) as PriorLC_to ; >>> from FilingDate fd1 left join FilingDate fd2 ; >>> on fd1.DsID=fd2.DsID ; >>> where fd1.rcode+fd1.town+fd1.ExtrYear+ ; >>> fd1.ExtrWeek = m.lcRtWeek ; >>> and fd2.rcode+fd2.town+fd2.ExtrYear+ ; >>> fd2.ExtrWeek = m.lcRtPriorWeek ; >>> order by 2,3 ; >>> into cursor TmpDates>>>