Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select records that fall 3 consecutive days within a wee
Message
From
22/12/2003 01:17:35
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
22/12/2003 01:10:11
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00861173
Message ID:
00861189
Views:
22
>hi hilmar,
>
>actually i have more than 20 lines of code to do that, i was just hoping i could do this in few lines using select - sql.
>
>thank for you reply anyway!

In some cases, a pure-SQL solution, if it is at all possible, can be inefficient. I suspect this is one of those cases.

Actually, I am starting to think that SQL can help you reduce code (but I am still doubting about the efficiency): something like
select * from MyTable where MyDate + 1 in (select MyDate from MyTable) and MyDate + 2 in (select MyDate from MyTable)
This should give you, as a starting point, the first date in each group of three. I never tried using more than one subquery in a query, so I don't know whether this works. Otherwise, you can probably split it into two queries.

From there, you can use another SELECT with subquery, to get the second and third date.

But I suspect that the loop, which you already programmed, would be much faster.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform