db_select group by of union
See this WEALTH OF DOCUMENTATION on Dynamic Queries in D7 ... it will answer EVERYTHING :) .... in all seriousness :).

To add SUM(blah) as foo you want to add an SQL Expression to your Select clause with addExpression().

To add Group by COLNAME you want to use groupBy() with your db_selection, see group by docs.