# 查询每日积分大于 $sum 的人数(注意having的顺序)
select count(*) rank from(SELECT sum( change_money ) rank_in
FROM `benben_user_change` WHERE `change_type` > 14 and add_time>{$start_time} and add_time<{$end_time}
GROUP BY `user_id`
HAVING rank_in >={$sum}) a
# 查询每日积分大于 $sum 的人数
select count(*) rank from(SELECT sum( change_money ) rank_in
FROM `benben_user_change` WHERE `change_type` > 14 and add_time>{$start_time} and add_time<{$end_time}
GROUP BY `user_id`
HAVING rank_in >={$sum}) a