Exercise: 40

Get the makers who produce only one product type and more than one model. Output: maker, type.

Solution

SELECT DISTINCT maker, type
FROM product
WHERE maker IN (
	SELECT maker
	FROM product
	GROUP BY maker
	HAVING COUNT(DISTINCT model) > 1
	AND COUNT(DISTINCT type) = 1
)

References