抄别人的: select id=(select count(*) from 表 where 主键<=a.主键),* from 表 a
--抄的好啊。兄弟。虽然感觉不是很完美,我整理一下。 -------------------------------------------- --测试数据 select a=111 into # union all select a=333 union all select a=222 union all select a=444 select * from # --测试数据 select myid=(select count(*) from # where a<=sex.a ) from # sex where a=222 --删除测试 drop table #
select id=(select count(*) from 表 where 主键<=a.主键),* from 表 a
--------------------------------------------
--测试数据
select a=111 into # union all
select a=333 union all
select a=222 union all
select a=444 select * from #
--测试数据
select myid=(select count(*) from # where a<=sex.a ) from # sex where a=222
--删除测试
drop table #