Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Code for a max expiration date???
Message
 
 
To
24/10/2002 08:40:44
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Miscellaneous
Thread ID:
00714536
Message ID:
00714832
Views:
21
Do you've index on ID field in rcbfile table? If you don't, create one. If you do, recreate it because it could be corrupted.
The query should return all records with expiration date in the specified interval and there's no record for the same ID with later expiration date. There's another way that could be faster than correlated query but it requires two queries.
ldStartDate  = {09/01/2002}
ldEndDate = {09/30/2002} 
* Get max expr. date for all Id's after start date
SELECT Id, MAX(expdate) AS MaxDate FROM rcbfile ;
  WHERE expdate >= ldStartDate ;
  INTO CURSOR crsMaxDate
* Get all records with expdate in specified interval
*  that don't have records with later expdate 
SELECT * FROM rcbfile ;
  WHERE expdate  BETWEEN ldStartDate AND ldEndDate ;
    AND Id + DTOS(expdate) IN ( SELECT Id + DTOS(MaxDate) FROM crsMaxDate )
* If Id is a number type field than
    AND STR(Id) + DTOS(expdate) IN ( SELECT STR(Id) + DTOS(MaxDate) FROM crsMaxDate )
>Sergey, the following code hangs on my computer at around 50%. I also tried on my co-workers computer. Any suggestions? Also, will this code still return all the records which have expired in a month but if a record has 2 the one with the max(expdate)?
>
>select * from rcbfile a ;
>where expdate between ctod('09/01/2002') and ctod('09/30/2002') ;
>and expdate ;
>IN( select max(expdate) ;
>from rcbfile b ;
>where b.id = a.id)
>
>Thanks,
>Sunshine
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform