Link to home
Start Free TrialLog in
Avatar of basilhs_s
basilhs_s

asked on

sql select statement counting the results

i am using sql server 2000. every time i am executing a select statement (f.e) select fielda, fieldb from table_a results come as follwing
 
a1 a2
b1 b2
c1 c2
d1 d2
..  ...

how can i create a column which will contains a increment by 1 counter. the select in this case should return

1  a1 a2
2  b1 b2
3  c1 c2
4  d1 d2
.......
........
.........
Avatar of SNilsson
SNilsson
Flag of Sweden image

You should be able to use the ROW_NUMBER function:

http://msdn.microsoft.com/en-us/library/ms186734.aspx
Avatar of basilhs_s
basilhs_s

ASKER

row_number is not supported in sql server 2000
ASKER CERTIFIED SOLUTION
Avatar of SNilsson
SNilsson
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
perfect answer for two reason. i saw how we count rows in sql server 2000 and since we are qoing to upgrade to sql sever 2008 soon i learned how i can use the row_counter() function there.. thanks very much