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 |
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2008-08-07 : 11:05:30
|
| hi,Can anyone help me count the number of posts a person has made in each message. ?I have a table that looks like :userid pid cid2 12 142 14 02 56 572 57 1012 101 05 5 07 122 1407 140 0How can I count the rows in such a way that my results are like :userid [count] originalid2 2 122 3 565 1 101 7 2 122Thank you for any help.jamie |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-07 : 11:15:39
|
| Have a look at recursive CTE on books online http://msdn.microsoft.com/en-us/library/ms186243.aspx |
 |
|
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2008-08-07 : 11:29:32
|
| ok, thank you, this example is perfect. |
 |
|
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2008-08-07 : 12:01:11
|
| hi, this example isn't really what I require.this basically would put my data in a similar format as my original table.What I really need is the second stage , ie, how to group and count those records..How can I count the rows in such a way that my results are like :userid [count] originalid2 2 122 3 565 1 101 7 2 122 |
 |
|
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2008-08-08 : 06:48:16
|
| hi,still struggling with this query.am using the recursive example to put my data in the correct format.however I need to beable to show the originalid in each row to do the grouping, does anyone know how to do that ?so consider :userid pid cid2 12 142 14 0needs to be :userid pid cid original2 12 14 122 14 0 12is this possible ?thank you for any help. |
 |
|
|
|
|
|