博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SQL WITH TIES
阅读量:4204 次
发布时间:2019-05-26

本文共 974 字,大约阅读时间需要 3 分钟。

http://msdn.microsoft.com/zh-cn/library/ms189463(v=sql.110).aspx

指定查询结果集包含与返回的最后一行中一个或多个 ORDER BY 列中的值匹配的任何其他行。 这可能导致返回的行数多于在 expression 中指定的值。 例如,如果 expression 设置为 5,而 2 个其他行与第 5 行中 ORDER BY 列的值匹配,则结果集将包含 7 行。

只能在 SELECT 语句中且只有在指定了 ORDER BY 子句之后,才能指定 TOP...WITH TIES。 返回的记录关联顺序是任意的。 ORDER BY 不影响此规则。

CREATE TABLE students(	id int IDENTITY(1,1) NOT NULL,	score int NULL) ON PRIMARYGOINSERT INTO students (score) VALUES (100)INSERT INTO students (score) VALUES (100)INSERT INTO students (score) VALUES (100)INSERT INTO students (score) VALUES (90)INSERT INTO students (score) VALUES (90)INSERT INTO students (score) VALUES (85)INSERT INTO students (score) VALUES (84)INSERT INTO students (score) VALUES (80)INSERT INTO students (score) VALUES (80)INSERT INTO students (score) VALUES (75)INSERT INTO students (score) VALUES (74)INSERT INTO students (score) VALUES (70)
SELECT TOP 8 * FROM students ORDER BY score DESC

SELECT TOP 8 WITH TIES * FROM students ORDER BY score DESC

转载地址:http://mpsli.baihongyu.com/

你可能感兴趣的文章
CSS单位和CSS默认值大全
查看>>
交大我来了--周末再见了
查看>>
网页中flash wmode属性
查看>>
挑战自我,勇攀高峰
查看>>
神奇的HTML5画图应用
查看>>
flex 滚动条问题
查看>>
软件开发管理中的博奕论
查看>>
计算机认证考试种类
查看>>
SQL in和exists 比较
查看>>
社会性网络服务(SNS)研究
查看>>
鼠标DarkField技术
查看>>
傻傻的我
查看>>
paypal 沙盒账号注册
查看>>
ebay 沙盒账号注册
查看>>
linux -8 Linux磁盘与文件系统的管理
查看>>
linux -8 Linux磁盘与文件系统的管理
查看>>
linux 9 -文件系统的压缩与打包 -dump
查看>>
PHP在变量前面加&是什么意思?
查看>>
ebay api - GetUserDisputes 函数
查看>>
ebay api GetMyMessages 函数
查看>>