In MS SQL Server 2008.
How do I count the number of rows that have a certain field in common.
Example, lets say I have the following table.
UserAccount_ID Attribute_ID
786 11
797 10
797 5
797 6
797 11
555 11
1003 10
1003 5
1003 6
1003 11
633 11
2036 11
2087 10
2087 5
2087 6
291 11
What query do I need to perform to get the following table. This will count the number of records with the same UserAccount_ID
UserAccount_ID Count
786 1
797 4
555 1
1003 4
633 1
2036 1
2087 3
291 1
1 Answer