select id, sum(amount) , percentage(groupsum/total) from XXXX group by id