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 results

Author  Topic 

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2003-02-04 : 04:23:14
Is it possible to number the results of a select statement? I am putting a hospital waiting list onto SQl server 7 and need to number the results of certain queries. For example I would need
select * from Patient

to return something like

1 Bloggs, Joe
2 Jones, Joe
.
.
.

So that if someone rings up we can give then an idea where they are on the waiting list and so how long before they will be seen

thanks in advance

steve
elwoosAThotmail.com

nr
SQLTeam MVY

12543 Posts

Posted - 2003-02-04 : 04:26:11
You can do it in the select statement if you have a unique field by just using count(*) in a subquery to get all the enrties ahead of this one.
Putting the result into a temp table with an identity and selecting from there will be more flexible though.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2003-02-04 : 04:38:35
that's great,

thanks

steve

Go to Top of Page
   

- Advertisement -