selecting when an aggregate column has two or more items
- by blockhead
Let's say I had a query like this:
SELECT * FROM (
SELECT 'a' AS a, '1' AS b
UNION
SELECT 'a' AS a, '2' AS b
UNION
SELECT 'b' AS a, '1' AS b) AS a
GROUP BY a.a
In this case "a".b is an aggregate of 1,2 while "b".b is only an aggregate of 1.
How can I select only "a"?