;with Details(ChargeDescription, Charge, Weight)as( select 'wrong address', 5.00, 2 union all select 'wrong address', 5.00, 3 union all select 'wrong weight', 3.00, 10)select ChargeDescription, SUM(Charge) as TotalCharges, (SUM(Charge) / (select SUM(Charge) from Details)) * 100 as PercentOfTotal, SUM(Weight) / (COUNT(*) * 1.0) as AvgWeightfrom Detailsgroup by ChargeDescriptionorder by ChargeDescription
SELECT Description, SUM(Charge) as TotalCharges,SUM(Charge) / (select SUM(Charge) from Table1) as PercentOfTotal,SUM(Weight) / COUNT(*) as AvgWeightfrom Table1group by Description