NULL Values in the Group Fields
You meet additional complications if there is NULL value in group field.
In WHERE statement while comparing two NULL values the result has NULL value (not TRUE), that is two NULL values are not considered the same. If you apply such sequence in GROUP BY statement it may occur that each record with NULL value in group field will be placed into the separate group containing this only record.
In practice this rule is very uncomfortable. That's why it is considered that two NULL values in GROUP BY statement are equal. If two records have NULL value in the equal group fields and identical value in all the others group fields they are placed into one group.