select @rownumber := case when @groupName1 = x.gn1 and @groupName2 = x.gn2
then (@rownumber + 1) else 1 end as 序号,
@groupName1 = x.gn1,
@groupName2 = x.gn2,
x.*
from
tableName x,
(select @rownumber := 0, @groupName1 = "", @groupName2 = "")
where 1=1
order by @groupName1,@groupName2

初始化变量,cross join[全连接]条件判断条件增加序号
1567

被折叠的 条评论
为什么被折叠?



