T-SQL query and group by reporting help
Posted
by Dayton Brown
on Stack Overflow
See other posts from Stack Overflow
or by Dayton Brown
Published on 2010-03-22T18:48:02Z
Indexed on
2010/03/22
18:51 UTC
Read the original article
Hit count: 267
So I have some data that looks like this.
`USERID1 USERID2`
1 10
2 20
2 30
3 40
3 50
1 10
2 20
2 30
3 50
I want a query that produces the following
`USERID1 COUNT`
2 2
3 2
It's a group by query that shows me the count of unique USERID2 for each USERID1 that has more than 1 USERID2 associated with it. God I hope you aren't as confused as I am by that last statement.
© Stack Overflow or respective owner