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"?
Question updated to be a bit clearer:
Let's take this very similar query:
SELECT *, GROUP_CONCAT(b) FROM (
SELECT 'a' AS a, '1' AS b
UNION
SELECT 'a' AS a, '2' AS b
UNION
SELECT 'a' AS a, '3' AS b
UNION
SELECT 'b' AS a, '1' AS b
UNION
SELECT 'b' AS a, '2' AS b
) AS a
GROUP BY a.a
Now a.b is 1,2,3 and b.b is 1,2:
I want to select a on the basis that it has 1, 2 and 3.