头痛的排名问题,急

softlife12 2004-04-29 04:36:31
有这样的数据

a b
1 添加时间1
5 添加时间2
2 添加时间3
4 添加时间4

要能search出"添加时间"〉添加时间4,并且按a进行order by的数据为
排名 a
1 5
2 2
3 1

谢谢
...全文
20 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
victorycyz 2004-04-29
  • 打赏
  • 举报
回复

select 排名=identity(int,1,1),a
into #t
from tablename
where b>'添加时间4'
order by a desc

select * from #t

drop table #t


zjcxc 2004-04-29
  • 打赏
  • 举报
回复

--处理思路是这样的
select 排名=(select count(*) from 表 where a>=a.a),a
from 表 a
where b>添加时间4
order by a desc
zjcxc 2004-04-29
  • 打赏
  • 举报
回复
添加时间4 是怎么查询到的?
dotbyte 2004-04-29
  • 打赏
  • 举报
回复
你的B列是datetime还是varchar

22,210

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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