-- 当月 最大最小排序 ,分组排序编号 加工基础数据A (总共 AB) SET @row_number1 :=0; SET @datee_uid1 :=‘‘; drop table orderinfo1017_1; create table orderinfo1017_1 as select (@row_number1:=case when @datee_uid1=concat(date_format(info.StartTime ,‘%Y-%m‘),info.MemberID ) then @row_number1+1 else 1 end ) num_mm1_ ,@datee_uid1 :=concat(date_format(info.StartTime ,‘%Y-%m‘),info.MemberID ) as datee_uid ,info.* from (select v_.* from orderinfo1017_ v_ order by MemberID,StartTime asc) info ,(Select @row_number1 :=0 ) as b order by info.MemberID ,info.StartTime asc