解决方案1
SELECT * FROM (SELECT * from tb_dept ORDER BY id desc LIMIT 100000) a GROUP BY parent_id order by id;
// 注: 不加 limit 可能会导致结果不正确>
解决方案2
SELECT b.* from douyin_fans b join( SELECT max(md_id) maxId FROM douyin_fans where time>= ‘.strtotime("-30 day").‘ GROUP BY member_id) mf on mf.maxId= b.md_id order by b.total_fans desc limit ‘.input(‘ limit/d ‘,0).‘, 30 ‘