关于with ties
对于with ties一般是和Top , order by相结合使用的,会查询出最后一条数据额外的返回值(解释:如果按照order by 参数排序TOP n(PERCENT)返回了前面n(pencent)个记录,但是n+1…n+k条记录和排序后的第n条记录的参数值(order by 后面的参数)相同,则n+1、…、n+k也返回。n+1、…、n+k就是额外的返回值)。
实验:
实验用表(PeopleInfo):
CREATE TABLE [dbo].[PeopleInfo](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [nchar](10) COLLATE Chinese_PRC_CI_AS NULL,
[numb] [nchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL,
[phone] [nchar](10) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [nchar](10) COLLATE Chinese_PRC_CI_AS NULL,
[numb] [nchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL,
[phone] [nchar](10) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
向表中插入数据:
insert into peopleinfo([name],numb,phone) values ('李欢','3223','1365255')
insert into peopleinfo([name],numb,phone) values ('李欢','322123','1')
insert into peopleinfo([name],numb,phone) values ('李名','3213112352','13152')
insert into peopleinfo([name],numb,phone) values ('李名','32132312','13342563')
insert into peopleinfo([name],numb,phone) values ('李欢','322123','1')
insert into peopleinfo([name],numb,phone) values ('李名','3213112352','13152')
insert into peopleinfo([name],numb,phone) values ('李名','32132312','13342563')
查看插入的全部数据:
select * from dbo.PeopleInfo
结果图:
操作步骤1:不用with ties
代码:
select top 3 * from peopleinfo order by [name] desc
结果如图:
操作步骤2:用with ties
代码:
select top 3 with ties * from peopleinfo order by [name] desc
结果如图:
如果with ties不与top和order by结合使用的错误示范:
操作步骤1:不与order by结合使用,只和top结合使用:
代码:
select top 3 with ties * from peopleinfo
错误消息如图:
操作步骤2:不与top结合使用,只和order by结合使用:
代码:
select with ties * from peopleinfo order by [name] desc
错误消息如图:
操作步骤3:不与top结合使用也不与order by结合使用:
代码:
select with ties * from peopleinfo
错误消息如图:
相关推荐
with ties一般是和Top , order by相结合使用的,会查询出最后一条数据额外的返回值,接下来将为大家详细介绍下,感兴趣的各位可以参考下哈
西门子全集成节能解决方案(TIES)pdf,西门子全集成节能解决方案(TIES):西门子是世界领先的节能环保企业,所提供的节能业务组合不仅是世界上最大而且涵盖了整个能源供应链条。利用自身在各个领域的世界领先技术及...
机器学习十大算法:K-means
Student(S#,Sname,Sage,Ssex) 学生表 Course(C#,Cname,T#) 课程表 SC(S#,C#,score) 成绩表 Teacher(T#,Tname) 教师表 问题: 1、查询“001”课程比“002”课程成绩高的所有学生的学号;... TOP 15 WITH TIES ...
研究发现:其实与一个人的工作和事业关系最密切的社会关系并不是“强关系”,而常常是“弱关系”。“弱关系”虽然不如“强关系”那样坚固(金字塔),却有着极快的、可能具有低成本和高效能的传播效率。
Ties.DB是一个去中心化的分布式数据库管理系统 实现的功能 功能列表在Ties.DB中实现 贡献代码和文档更改 贡献者可以克隆存储库并遵循准则: 有关Ties.DB的更多信息,请访问:
4.当我们在统计排名的时候,如果出现相同的排名要记得使用 with ties。 5.order by 默认升序排序,也可以用ASC标识,降序desc。 6.distinct 去重复 7.批插入 insert into table_name select __________union ...
22、--查询如下课程成绩第 3 名到第 6 名的学生成绩单:企业管理(001),马克思(002),UML (003),数据库(004) --[学生ID],[学生姓名],企业管理,马克思,UML,数据库,平均成绩 SELECT DISTINCT top 3 SC....
西门子全面节能解决方案(TIES) - 英文版pdf,西门子全面节能解决方案(TIES) - 英文版
领带2.0 TIES是我的本科论文,表格信息提取系统。 我从那里选择了名称,然后从那里开始命名为2.0。 这是一个存储库,其中包含arxiv论文1905.13391()的源代码。 该论文已被ICDAR 2019接受。要引用该论文,请使用: ...
ties and lengthy explanations, this Visual QuickProject Guide uses big illustra- tions coupled with clear, concise step-by-step instructions to show you how to complete a specifi c project in a ...
主体框架:逻辑架构ASP、NET MVC,物理架构Three Ties,2者相结合。 为了提高网站自由排名,白帽子SEO DIV + CSS布局手把手全程示范 使用Jquery完成ajax无刷新...第三方组件FckEditor、CodeSmith详细配置及实战应用
In order to resolve the fundamental difficul-ties of CCA, we have set up a sound theoretical basis for completeness of covert channel identification and have proposed a unified framework for covert ...
Component Object Model (COM) is the glue that ties all of these pieces together. It enables programmers and companies to distribute and reuse their code efficiently. The more you know about COM, the ...
Java Persistence with Hibernate, Second Edition explores Hibernate by developing an application that ties together hundreds of individual examples. In this revised edition, authors Christian Bauer, ...
swift实现的IOS APP带领结功能,可以实现基本的带领结功能,可以显示领结图像,带领结次数,给试带评分等功能。
This book is divided into three major sections.... We hope that students will appreciate that the study of simulation ties together, or unifies, material from a number of separate areas of study.
该项目调查正在经历进化,个体和社会学习的新兴特工社会。 该项目涉及一个代理建模环境,监视机制,仿真引擎和一个分布式p2p平台。 所有这些都在Java中。