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

alexwoowf 2003-01-07 11:57:11
有一表: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.........
...全文
144 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
lizongqi 2003-04-21
  • 打赏
  • 举报
回复
up
pengdali 2003-01-07
  • 打赏
  • 举报
回复
看不懂题目!
是:
select field1,(select count(*)+1 from table where right(field1,5)<right(A.field1,5)) from table A
吗??
alexwoowf 2003-01-07
  • 打赏
  • 举报
回复
这个问题很好笑吗?chiff(一对翅膀)~!·#¥%……—
alexwoowf 2003-01-07
  • 打赏
  • 举报
回复
请注意看题,应该说得很清楚了吧?
Chiff 2003-01-07
  • 打赏
  • 举报
回复
呵呵呵...
愉快的登山者 2003-01-07
  • 打赏
  • 举报
回复
select (select count(itemno) from tablename where itemno < A.itemno ) as rownum,
* from tablename as A order by itemno
hjhing 2003-01-07
  • 打赏
  • 举报
回复
select identity(int,1,1) as sno, field1
into #tt
from tableA
order by field1

select * from #tt
hjhing 2003-01-07
  • 打赏
  • 举报
回复
select field1,(select count(*) from table where right(field1,5)<right(A.field1,5))+1 as rowsid from table A

34,837

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧