I'm a bit new to SQL; I have a single table Products:
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
I need to select maker an type by maker who has more than 1 model but all of those model are of a single type. So the output should be
maker type
D Printer
When I perform grouping only by maker everything is ok, but when use both maker and type = everything goes wrong :( Is that possible to perform group by a single column but have 2 in output? The correct response without a type returns next query:
Select maker from product
group by maker
having count(model)>1
and count(distinct type)=1
But when I select maker,type - it goes wrong :( also wrong when use select maker,type and group by maker,type
Spent about 4 hours to solve that, will very appreciate your help Thanks in advance!