如下数据:
活动id 批次id 批次开始时间 期望序号
1 1 09:00 1
1 2 09:01 2
1 3 09:05 3
2 4 08:55 1
2 5 09:00 2
.........
活动id :choose_room_activity_id
批次id: choose_room_batch_id
开始时间: start_date
表名:ztc_choose_room_batch
select a.choose_room_activity_id,a.choose_room_batch_id,count(*) as 序号,a.start_date from ztc_choose_room_batch as a
INNER JOIN ztc_choose_room_batch as b
ON a.choose_room_activity_id=b.choose_room_activity_id and a.start_date >= b.start_date group by a.choose_room_activity_id,a.choose_room_batch_id ORDER BY a.start_date asc;