with rank as(
SELECT group_id, SUM(pay_dollar) as pay_dollars, count(*) as count FROM
(select mod(player_id, 33) as group_id, pay_amount*exchange as pay_dollar FROM mafia1.v_paid_order
WHERE pay_time >='2019-10-24 06:10:00' and pay_time <='2019-10-31 03:10:00' and player_id not in (select player_id FROM mafia1.create_player where uid in (select uid from mafia1.internal_user)))
# and player_id in (select player_id FROM mafia1.create_player where timestamp >='2019-07-01'))
#where pay_dollar >=90
group by group_id
order by pay_dollars)
select group_id, pay_dollars/total_dollars as ratio, count, pay_dollars, pay_dollars/count as mean FROM rank, (select SUM(pay_dollars) as total_dollars FROM rank)
Order by pay_dollars
with rank as(
SELECT group_id, SUM(pay_dollar) as pay_dollars, count(*) as count FROM
(select mod(player_id, 33) as group_id, pay_amount*exchange as pay_dollar FROM mafia1.v_paid_order
WHERE pay_time >='2019-10-30 13:15:00' and pay_time <='2019-10-31 03:10:00' and player_id not in (select player_id FROM mafia1.create_player where uid in (select uid from mafia1.internal_user)))
# and player_id in (select player_id FROM mafia1.create_player where timestamp >='2019-07-01'))
#where pay_dollar >=90
group by group_id
order by pay_dollars)
select group_id, pay_dollars/total_dollars as ratio, count, pay_dollars, pay_dollars/count as mean FROM rank, (select SUM(pay_dollars) as total_dollars FROM rank)
Order by pay_dollars