UNION
を使用して、グループ化された各クエリを他のクエリと組み合わせることができます 。各サブクエリの未使用の列にNULL
を入力します 。
SELECT FirstName, LastName, NULL AS Country, NULL AS City, NULL AS BirthMonth, COUNT(*) AS count
FROM my_table
GROUP BY FirstName, LastName
UNION ALL
SELECT NULL, NULL, Country, City, NULL, COUNT(*)
FROM my_table
GROUP BY Country, City
UNION ALL
SELECT NULL, NULL, NULL, NULL, BirthMonth, COUNT(*)
FROM my_table
GROUP BY BirthMonth