Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tricky select
Message
From
29/11/2001 13:36:42
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00587576
Message ID:
00587618
Views:
20
Wouldn't :

...where record_fm != '' and ExtrYear+ExtrWeek = (select max(ExtrYear+ExtrWeek) ... where ExtrYear+ExtrWeek < CuurentWeek)

work?
Cetin

>Hi,
>
>Me again. Sometimes it really helps to explain the problem. I think, figured this one out. I would need several selects instead of one...
>
>Something like:
>
>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...
>
>>Hi everybody,
>>
>>Is there a way to create a cursor, which contains information about current record in the table and the most closest date, where it has data.
>>
>>Currently I have this SQL:
>>
>>	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
>>
>>However, lcRtPriorWeek is different for each town and should be the week, when last time information was recorded prior to the current date.
>>
>>Can this select statement be modified or I need to use scan loop through the table and find it one by one. If so, how can I construct my index?
>>rcode+town+ExtrYear+ExtrWeek descending, right?
>>
>>Thanks in advance.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform