Reputation: 889
Consider the following rows that is returned from a query:
name number
foo 1
foo 9
foo 10
foo 11
bar 12
bar 13
dumb 14
How do I select the name where the number of such name is never under 10, and appear at least twice so this case, i wanted it to return
name
bar
What I have tried:
select name from my_table
where number >= 10 #<--Problem
group by name
having count(*) >=2
This works partially because it was not able to filter out foo. The problem of this query is that it will be able to filter out foo 1
and foo 9
but foo 10
and foo 11
will be returned.
Upvotes: 0
Views: 21
Reputation: 18474
select name from my_table
group by name
having count(*) >=2 and min(number) >= 10
Upvotes: 5