Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Numbering rows in sequence without cursors

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-10-26 : 20:04:12
Jason writes "I need a way to return rows with an extra field that numbers them in sequence.

For example take a many to many relationship that links students to classes. A teacher wants to perform a query that returns all students in a class, in alphabetical order, numbered in sequence. ie. Adam,1 Bob,2 Carl,3

Of course for a diferent class Bob could end up being numbered 3 or 1 depending on the other students.

I know that this can easly be done in code but the thing is that I need to JOIN the result with another table while preserving the sequence number. This operation will be done on a server that takes heavy internet traffic and needs to be fast.

The benefit I get from doing this is that my result is smaller (instead of 6 digit IDs for 100s of records I get 1 or 2 digit IDs). The algorithm I use on the client can also handle the result faster too.

PS: This is actually for an internet graphing application. Students represent a graph series.

Versions: SQL Server 2000 Beta, Windows 2000
"
   

- Advertisement -