mysql 排名实例
select item.*, @rank := @rank + 1 AS personRank from ( select detail.entity_id, sum(detail.amount) as sumAmount from bonus_plan_calculate_detail detail where detail.plan_id in (1) and detail.entity_type = 0 and detail.entity_id in (1) group by detail.entity_id order by sumAmount desc ) item, (SELECT @rank := 0) r;
结果:
随笔看心情