我做的一个项目 每行有2个东西需要排序,所以不能用页面中jstl循环的索引读序列号,怎么在mysql里面设置一个排序的序列号,我点流入量排序 他就会排序,排序号就会改变,而流入量的不改变、create table pv(
id int,
type varchar(4)
)报表如下:
流入量 排序号 流出量 排序号
5 1 2 3
2 2 3 2
1 3 4 1select count(if(type="in",1,null)) as 流入量
count(if(type="out",1,null)) as 流出量
from pv
id int,
type varchar(4)
)报表如下:
流入量 排序号 流出量 排序号
5 1 2 3
2 2 3 2
1 3 4 1select count(if(type="in",1,null)) as 流入量
count(if(type="out",1,null)) as 流出量
from pv
MySQL中的ROWNUM的实现
selec @a:=@a+1,column1
from tb;
set @b:=100
select @b:=@b-1,column1
from tb;