I would add to that:
beware of the catastrophic effect a 'group by' can have if your query contains cascading Views (or CTEs).
The query optimizer of many DBs is capable of pushing the predicate down through a series of nested Views (or CTEs) but that process is immediately blocked by a 'group by' in the cascade.
Certainly, that was the case with the Oracle optimizer up to version 11