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 |
DanielS
Starting Member
32 Posts |
Posted - 2013-11-28 : 22:57:29
|
Hello all, I am looking to create a column of data which only counts by like cells from two other fields. My data is ID and Type, I'm looking ot produce the Count:ID Type CountA X 1A X 1B X 1B X 1A Y 2A Y 2B Y 2B Z 3I couldn't do this via a standard COUNT or via a ROW() PARTITION. Is the best way to concateante ID and Type? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-11-28 : 23:03:51
|
wont this be enough?SELECT ID,Type, DENSE_RANK() OVER (ORDER BY Type) AS [Count]FROM Table ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
DanielS
Starting Member
32 Posts |
Posted - 2013-11-28 : 23:44:06
|
That's it, thanks Visakh16. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-11-29 : 00:07:44
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|