This will not produce the correct results
Code:
SELECT COUNT(*) FROM ... WHERE grp IN ( ... ) GROUP BY ...
because the count will be computed
for each group and you don't get a count of groups.
My query had the problem that it didn't give the temp table a name. Adding a "AS t" at the end will do the trick.
And n_i's approach is the easiest and most straight-forward.