开发者

Counting the size of a group in T-sql

I'd like to count the size of a group.

My table looks like that:

Name            Number
Renee Scott     1
Bruno Cote      1
Andree Scott    2
Renee Scott     2
Pierre Dion     2
Pierre Dion     3
Louise Tremblay 3
Renee Scott     3
Andree Scott    3
Jean Barre      3
Bruno Cote      3

There are 2 Name associated with the Number 1, 3 Name with Number 2 and 6 Name with 3. I'd like to select this开发者_开发技巧 table where the Number is associated with 3 name or more.

Thank you.


SELECT * FROM TABLENAME WHERE NUMBER IN
(
   SELECT NUMBER FROM TABLENAME GROUP BY NUMBER HAVING COUNT(*)>3
)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜