我的桌子是
产品(制造者、型号、类型)
我想选择类型和制造商的类型,只有相同的类型,并有超过一个的型号计数。
样本数据:
maker model type
-------------------------------------
A 123 computer
B 234 laptop
B 345 laptop
C 456 printer
C 543 PC上述样本数据的答案是B和膝上型计算机,因为maker B只生产笔记本电脑,而且多个model.It并不是A制造商,因为即使他生产相同类型的产品,他也只有一个型号。
发布于 2014-02-21 23:35:02
这很简单。您正在寻找记录计数>1、类型不同的计数=1的制作者:
select maker
from product
group by maker
having count(distinct type) = 1 and count(*) > 1;发布于 2014-02-21 23:36:01
试试这个:
SELECT maker
FROM Product
GROUP BY maker, type
HAVING COUNT(1) > 1https://stackoverflow.com/questions/21947235
复制相似问题