Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Count number
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00335161
Message ID:
00335193
Views:
18
>>I would like to create a SQL query in which one column contains a counter that increments by one for each record in the query result. This would be just like the count function which can be set for a report in the report designer. However I can't seem to find any function that would generate the numbers into the query result. As this must have come up at other times, I am hoping that some one might be able to give me an idea in this regard.
>>
>>Thanks
>>
>>Porter Bailey
>
>If the query is not ordered
>SELECT *, recno() as counter from mytable into cursor temp
>should be fine.
>
>If it is ordered you can do the same, SELECT *, recno() as counter ORDER by myfield from mytable into cursor temp
>then
>USE DBF("temp") in 0 AGAIN ALIAS temp1
>SELECT temp1
>REPLACE all counter with RECNO()
>
>Nick

It worked exactly as required. The question involves ordered queries. I haven't quite got my mind around what the code does, but it does it, and I will work through the code next.

Thanks

Porter Bailey
Previous
Reply
Map
View

Click here to load this message in the networking platform