create table test(id int,value nvarchar(10))
insert test
select 1,'没' union all
select 2,'有' union all
select 3,'测' union all
select 4,'试' union all
select 5,'数' union all
select 6,'据' select a.id,a.value
from (
select RowNumber = ROW_NUMBER() OVER(ORDER BY id DESC),
id,
value
from test
) a
where a.RowNumber=2
name sex phone score
张三 男 123123 55
。
。
。
。
就比如这样的
select *
from (
select row_number()over(partition by name order by score)id,*
from 你的结果集
)a
where id=2
(
select row_number()over(partition by name order by score
)
d,*from
(
select top 3 * from charts order by Score desc
)a where id=2
消息 102,级别 15,状态 1,第 8 行
'2' 附近有语法错误。
因为row_number() over 没用过 不了解
select * from
(
select row_number()over(partition by name order by score desc
)
d,*from charts)a where id=2是这个语句吧 不过查出来的不对啊
(
select row_number()over(partition by name order by score desc)id,*
from charts)a where id=2你多了一个括号,少了一个i...用我上面的,另外如果数据不对,你要考虑一下那个desc还是asc
按我这个格式来写 把表名和列名改下就行了!