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.
| Author |
Topic |
|
markj11
Starting Member
17 Posts |
Posted - 2008-01-17 : 09:34:53
|
| How can I create a counter (line#) by group were it resets = 1 whenever a new group starts.Customer Line#A 1A 2A 3B 1C 1C 2 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-17 : 09:41:40
|
| Try:-SELECT ROW_NUMBER() OVER(PARTITION BY Customer ORDER BY Customer) AS LineNo,CustomerFROM Table |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-17 : 09:44:28
|
MadhivananFailing to plan is Planning to fail |
 |
|
|
markj11
Starting Member
17 Posts |
Posted - 2008-01-17 : 09:56:46
|
| Thanks, works great. I wouldn't exactly call myself a rookie but I've never even heard of row_number, over, or partition. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-18 : 01:00:59
|
quote: Originally posted by markj11 Thanks, works great. I wouldn't exactly call myself a rookie but I've never even heard of row_number, over, or partition.
Then read the link I postedMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|