ROW_NUMBER() over(partition by 分组字段 order by 排序字段)

select *, ROW_NUMBER() over(partition by user_id order by is_main_post desc,enable_time) as t FROM s_user_post
mysql 分组排序_字段
T 则表示 组内排序第几个

注意:只支持mysql 8.0 以上!!!!