您的位置:程序门 -> .net技术 -> c#



sql怎么实现某条记录的一字段值在表里的排名


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


sql怎么实现某条记录的一字段值在表里的排名
发表于:2007-01-15 09:07:18 楼主
sql怎么实现某条记录的一字段值在表里的排名

如字段point为int型,不是主键,也不是自动编号,想要知道某条记录的point值在此表中居第几位,这样的sql要怎么写啊???
发表于:2007-01-15 09:11:331楼 得分:0
select     no=identity(int,1,1),point   into   #t   from   t  
  where   point   = ' '
你返回no就可以了

发表于:2007-01-15 09:16:512楼 得分:0
#t   是什么啊,


发表于:2007-01-15 09:22:413楼 得分:0
select   count(*)   +   1   from   table1   where   point   >   78   // <-你的point值,应该是个int
发表于:2007-01-15 09:24:294楼 得分:0
楼主试试是不是这样的:
declare   @count   int
set   @count=0
select   @count=@count+1
                from   table
                where   (point   <=   @point)
                group   by   point
                order   by   point

select   @count
发表于:2007-01-15 09:26:495楼 得分:0
#t   是临时表

用select   *   from   #t   可以查看


快速检索

最新资讯
热门点击