2012-12-11 173 views
0

找出谁只能生产同类型的模型制造商,而这些车型的数量超过1分组和汇总值

maker model type 
A  1232 PC 
A  1233 PC 
A  1276 Printer 
A  1298 Laptop 
A  1401 Printer 
A  1408 Printer 
A  1752 Laptop 
B  1121 PC 
B  1750 Laptop 
C  1321 Laptop 
D  1288 Printer 
D  1433 Printer 
E  1260 PC 
E  1434 Printer 
E  2112 PC 
E  2113 PC 

结果应该是

Model Type 
    D  Printer 

我试过

Select maker,type from Product 
    Group by maker ,type 
    Having count(*)>1 

上述查询给我的制造商的模型数超过一个。但我不能找到模型WHIC h只生产相同类型。请帮助

回答

2
Select Distinct Maker, Type From Product 
Where Maker In (Select Maker From Product 
        Group By Maker 
       Having Count(Distinct Type) = 1 
        And Count(Distinct Model) > 1) 
+0

Thnks很多工作 – Venaikat