2012-12-11 172 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