Fixing select count

This doesn't work for all queries.
For instance, if the query is: select xxx from aaa group by bbb
Then select count from aaa group by bbb is not the same as select count(*) from (select xxx from aaa group by bbb)