SQL: Add counters in select

Posted by etarvt on Stack Overflow See other posts from Stack Overflow or by etarvt
Published on 2010-06-03T11:33:31Z Indexed on 2010/06/03 11:44 UTC
Read the original article Hit count: 735

Filed under:
|

Hi,

I have a table which contains names:

Name
----
John Smith
John Smith
Sam Wood
George Wright
John Smith
Sam Wood

I want to create a select statement which shows this:

Name

'John Smith 1'

'John Smith 2'

'Sam Wood 1'

'George Wright 1'

'John Smith 3'

'Sam Wood 2'

In other words, I want to add separate counters to each name. Is there a way to do it without using cursors?

© Stack Overflow or respective owner

Related posts about sql

Related posts about counter