您的位置:首页 > 其它

with ties 的用法

2015-11-12 18:34 211 查看
create table #Stuscore

(

name nvarchar(20),

score int

)

insert into #Stuscore values ('陈一',100),('张二',100),('王五',90),('李四',80);

select top 1 with ties * from #Stuscore order by score desc

如果不加with ties 结果如果用并列的,只能查出一个,如上面的例子中,如果写成

select top 1 * from #Stuscore order by score desc,就只能查出张三这一条,但我们的本意是查出最高成成绩的学员,因此这时用with ties就体现出它的作用了。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: