分组情况下还想要给序列展示自增序号时,需要将查询出来的数据做为子句,与 (select @i:=0)i 联查
SELECT
(@i:=@i+1) xh,a.yearMonDay,a.collectAll
from (select
DATE_FORMAT(create_date,'%Y-%m-%d') yearMonDay,
count(1) collectAll
from tb_order_info
group by DATE_FORMAT(create_date,'%Y%m%d')
order by DATE_FORMAT(create_date,'%Y%m%d') desc) a,(select @i:=0)i