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
 Transact-SQL (2000)
 About Rownumber

Author  Topic 

SQL2000User
Starting Member

13 Posts

Posted - 2006-11-17 : 10:00:56
Hi,
I know how to select row number , but getting the problem to put this data as one column of the table.
If there is anyway to do it without temp table

The way I select the row number is :


SELECT COUNT(*) AS [Row Number], c.CustomerID, c.CustName
FROM Customer c, Customer d
WHERE d.CustomerID <= c.CustomerID
GROUP BY c.customerID, c.CustName
ORDER BY c.customerID


Thanks

Flora

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-11-17 : 10:15:04
in sql 2005 you have the row_number() function. look it's use in BOL.

it's better to store your result in temp table with identity and select from that,
than doing a self join on the table.

numbering should be done in front end though.



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-11-18 : 05:00:49
>>numbering should be done in front end though.

I agree with you

Flora, where do you want to show data?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -