sql:对字段排序并取其序号

有一表:field1
200201011
200201091
200201033
200201045
200201045 如何让他新增itemno列
1
5
2
3
3
(在http://expert.csdn.net/Expert/topic/1275/1275333.xml?temp=.0584833中有这个问题,不过最终crazyfor(现在不知改成什么了*^_^)的答案是从0开始的
select field1,(select count(
) from table where right(field1,5)<right(A.field1,5)) from table A
我将〈改成〈= 后从1开始,但是itemno是1 5 2 4 4! help.........

---------------------------------------------------------------

看不懂题目!
是:
select field1,(select count(*)+1 from table where right(field1,5)<right(A.field1,5)) from table A
吗??

---------------------------------------------------------------

select field1,(select count(*) from table where right(field1,5)<right(A.field1,5))+1 as rowsid from table A

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus