sql查询时怎样跟据采购单号条件查出后,序号自动从1开始编号。
select (select count(1)+1 from tb_cgxd2 as b where b._id<tb_cgxd2._id) _id,_pp from tb_cgxd2
这样是会自动从1顺序显示序号的。
select (select count(1)+1 from tb_cgxd2 as b where b._id<tb_cgxd2._id) _id,_pp from tb_cgxd2 where _cgdh='120621163301'
这个我在后在加了采购单号查询。序号就不再是从1开始顺序显示了。要怎样改才可以呀?那位高手指点一下呀。先感谢了。
显示如图,序号不连续了。怎样才能连续编号呢?
------解决方案--------------------
select (select count(1)+1 from tb_cgxd2 as b where b._id<tb_cgxd2._id and _cgdh='120621163301') _id,_pp from tb_cgxd2 where _cgdh='120621163301'