开发者

more than 3 entries in the column [closed]

开发者 https://www.devze.com 2023-04-06 07:51 出处:网络
It's difficult to tell what is being asked here. This question is ambi开发者_StackOverflow社区guous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its curr
It's difficult to tell what is being asked here. This question is ambi开发者_StackOverflow社区guous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I have a table say XYZ, there are three entries for each entity of the column say 'a' and I want to find out if there are more than 3 entries for those entities in the column.

column:

    a      b      c
    123
    123
    123
    sol
    sol
    sol
    456
    456
    456

Here I want to know if I have more than 3 entries for 123 or sol or 456 in the tab


SELECT a, count(a) from YOURTABLE group by a having count(a) > 2
Since you didn't provide a table name i just placed "YOURTABLE" there.


Just try somthing like this, i did not test the sql but you understand the ideea

select a 
from your_table 
where 
   (select count(*) 
    from your_table 
    where a = 'your_entity') > 3
0

精彩评论

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