Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL - Incrementing number
Message
From
30/03/2004 14:23:03
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
30/03/2004 14:14:41
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00890936
Message ID:
00890939
Views:
20
>Hi All,
>
>Is there a way to put into a SQL - Select statement a number that increments by 1 and resets at when a value changes? For instance an incrementing number that resets at each zip code.
>
>Aloha,
>
>James

In principle no, because you have no control in which order the records will be processed. However, if you do a first SELECT into a cursor (with the NOFILTER clause), then it is likely that SELECTing from this cursor will process the records in order. In this case, I would create a UDF, which accepts the key field as a parameter, increments a global variable or a value in a table, and resets when the value changes.
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