帮我编写查询,选择供应商名称大于2的城市名称
ID Name City emp_count vendor
'1' 'Sprox' 'RAJ' '23' 'es'
'2' 'Raj' 'RAJ' '4' 'es'
'3' 'juli' 'BAN' '4' 'bob'
'4' 'crafer' 'BAN' '5' 'axe'
查询:
select city from test.org where 2= (select count( vendor )from test.org group by vendor) ;
答案 0 :(得分:0)
这个怎么样 -
SELECT city, COUNT(vendor)
FROM test.org
GROUP BY city
HAVING COUNT(vendor) > 2;
答案 1 :(得分:0)
select city,vendor, count(*)
from t
group by city,vendor
having count(*) >= 2