select uid, month, sum(coin) as coin from ( select uid, month, tmp, case when cnt%7<3 and cnt%7>0 then floor(cnt/7)*15+cnt%7 when cnt%7>=3 then floor(cnt/7)*15+cnt%7+2 when cnt%7=0 then floor(cnt/7)*15 end as coin from ( select uid, month, tmp, count(tmp) as cnt from ( select uid, month, dt...