Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to check previous record value
Message
From
21/07/2006 09:51:52
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
21/07/2006 09:41:29
Rasheed Al Rasheed
Riyadh Armed Forces Hospital
Riyadh, Saudi Arabia
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01138406
Message ID:
01138422
Views:
12
>Hi All;
>
>I have a several hundreds thousands records in a table which I need to compare the closing value of each record with the previous one.
>I used the following code
>
>Option 1
>
>go top
>scan
> nVal1 = nClsVal
> skip
> nVal2 = nClsVal
> skip -1
> rest of code
>endscan
>
>too slow.
>
>option2
>select A.*, 000000000 as nRecNo from table1 to Cursor cTbl_1 readwrite
>then replace the nRecNO with Recno() all
>
>select A.*, 000000000 as nRecNo from table1 to Cursor cTbl_2 readwrite
>then replace the nRecNO with Recno()-1 all
>
>Finally
>select a.*, b.nClsVal as nPrvVal ;
>from cTbl_1 a, cTbl_2 b ;
>where a.nRecNo = b.nRecNo ;
>into cursor cTmp
>
>This is far more faster than option 1 but done in 3 sql select statement.
>
>Is there is any suggestion for a more elegent way
>
>Thanks all
use tableA in 0 again alias tablePrev
select tableA
set relation to recno()-1 into tablePrev
Cetin
Ç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
Reply
Map
View

Click here to load this message in the networking platform