SELECT uid, month, SUM(CASE WHEN MOD(rnk_1, 7) = 3 THEN 3 WHEN MOD(rnk_1, 7) = 0 THEN 7 ELSE 1 END) AS coin FROM( SELECT uid, month, RANK() OVER(PARTITION BY uid, DATE_SUB(dt, INTERVAL rnk DAY) ORDER BY dt) AS rnk_1 FR...