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 |
|
bondwiththebest
Starting Member
46 Posts |
Posted - 2009-05-08 : 16:01:09
|
| Hi,I have the results of the query like this below.............The "Total" value should be like something shown below..ID CID Total Value13 AA 3 820 4 AA 3 1640 5 AA 3 1221 6 AB 2 820 7 AB 2 1640 I have this results in a temp table.Here the "total" needs to increment by value 1 ,max out and reset. I want the output of the query like this. Can anyone help ,me >?ID CID Total Value13 AA 1 820 4 AA 2 1640 5 AA 3 1221 6 AB 1 820 7 AB 2 1640 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-05-08 : 16:05:28
|
[code]select ID, CID, row_number() over (partition by CID order by ID ) as Total, Value1from table[/code] No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|