select * from ( select user_id,sum(money) as sum_money from 记录用户消费的表 where `type`=1 and `add_time`>=date_add(curdate(),interval -7 day) group by user_id ) t order by sum_money desc limit 5
select user_id,sum(money) as total_money from 用户消费的表 where type=1 and date(add_time)>date(now()+interval -7 day) group by user_id order by total_money desc limit 5
from (
select user_id,sum(money) as sum_money
from 记录用户消费的表
where `type`=1
and `add_time`>=date_add(curdate(),interval -7 day)
group by user_id
) t
order by sum_money desc
limit 5
距今天前七天之内