Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Next and Previous
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00426536
Message ID:
00428034
Views:
19
>Can anyone think of a simple way to grab a value from a field in the record immediately before and after the current record, without changing the current record? It has to respect the sort order as well.
>
>It seems like it should be simple, but it's just not coming to me...
>
>Thanks,
>
>Michelle

You probably don't need it now, and it might even be slower, but you can do it with SQL using an "offset" self-join. It is something like:

SELECT stuff FROM yourtable INTO CURSOR step1 NOFILTER ORDER BY whatever
SELECT *, RECNO() AS counter FROM step1 INTO CURSOR step2 NOFILTER ORDER BY counter
SELECT step2A.stuff, step2B.something, somefunction(step2A.whatnot,step2B.whatnot,step2C.whatnot) AS importantresult FROM step2 AS step2A INNER JOIN step2 AS step2B ON step2A.counter = step2B.counter - 1 INNER JOIN step2 AS step2C ON step2B.counter = step2C.counter - 1 ORDER BY step2B.counter.

You may have to reverse signs, or something.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform