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)
 need an incremental number

Author  Topic 

icw
Constraint Violating Yak Guru

378 Posts

Posted - 2010-01-14 : 10:23:20
Hi
I originally posted this into the wrong forum.

Hi
I don't know how to do this.
I have a sales table.
The table has the following columns (this is simplified of course)
Date, Userid, UniqueSaleid, Product, amount

I want to do a query that will add an incremental number column. but the number has to reset each month for each user.

E.g. the results might look like this
Unique Date Userid IncrementalNumber
31231 12/12/09 Jim 1
12313 14/12/09 Jim 2
34555 15/12/09 Mary 1
65455 17/12/09 Jim 3
76556 17/12/09 Mary 2
55554 26/12/09 Jim 4
44344 03/01/10 Jim 1
98777 03/01/10 Jim 2
21123 04/01/10 Jim 3
86756 04/01/10 Mary 1
45454 16/01/10 Mary 2

hope that makes sense

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-01-14 : 10:27:33
Duplicate post
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=138355
Some answers are given there...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -