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 |
|
Grifter
Constraint Violating Yak Guru
274 Posts |
Posted - 2011-09-27 : 12:24:29
|
HiHow do I show the count of each grouping in the same row as each counted value, like this:Animal Count====== =====CAT 3CAT 3CAT 3DOG 2DOG 2 It's like I need to do a count and grouping then use that against the original dataset without the grouping, I take it there would be a sub query with a self-join or similar, I am not sure?ThanksG |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-27 : 12:27:56
|
| [code]SELECT Animal,COUNT(1) OVER (PARTITION BY Animal) AS [Count]FROM table[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|