开发者

Counting the size of a group in T-sql

开发者 https://www.devze.com 2023-04-10 04:07 出处:网络
I\'d like to count the size of a group. My table looks like that: NameNumber Renee Scott1 Bruno Cote1 Andree Scott2

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

精彩评论

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