select sum(every_people_money) as sales_total, round(sum(every_people_money)/count(user_id), 2) as per_trans from ( select user_id, sum(sales_price) as every_people_money from sales_tb group by user_id ) as a;