Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replace sno conditionaly
Message
From
05/12/2005 01:13:57
 
 
To
05/12/2005 00:01:46
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01074825
Message ID:
01074834
Views:
14
This message has been marked as the solution to the initial question of the thread.
I'm assuming that you have an index on Group and Date (Grp + DTOS(date))
SELECT myTable
SET ORDER TO CorrectTag
GO TOP
m.grp = grp
DO WHILE grp = m.grp AND NOT EOF()
     m.date = date
     m.sno = 0
     DO WHILE m.grp = grp AND m.date = date AND NOT EOF()
          m.sno = m.sno + 1
          REPLACE sno WITH m.sno
          SKIP
     ENDDO
     m.grp = grp
ENDDO
>Dear Experts
>
>Table1 has following three fields
>
>grp c(1)
>sno n(3)
>date d()
>
>Data in table1 is as
>
>A, 5, 01-12-2005
>A, 1, 01-12-2005
>A, 3, 01-12-2005
>B, 2 01-12-2005
>B, 4, 01-12-2005
>
>I want to replace sno according to unique grp, in same date, as follows
>
>A, 1, 01-12-2005 && here sno will replace by 1
>A, 2, 01-12-2005
>A, 3, 01-12-2005
>B, 1, 01-12-2005 && here sno will replace by 1 again
>B, 2, 01-12-2005
>
>Grp,A,B, means group.
>Every new group must start with 1 and should continue increasing by 1 till
>end of same date.
>
>There are diffrent dates in table1.
>
>Please help
Previous
Reply
Map
View

Click here to load this message in the networking platform