在我的表格中,我尝试从BusinessEntityID列中选择并按从最低38位到最高位2357的升序排序。当我执行此查询时,我没有得到结果我正在寻找我获得第一个前十行而不是。
没有订购依据
USE [AdventureWorks2014] --Database Name
Select top 10 [FirstName], [LastName], [BusinessEntityID]
From [AdventureWorks2014].[Person].[Person]
结果:
FirstName LastName BusinessEntityID
------------------------------ ----------------------------------- ----------------
Syed Abbas 285
Catherine Abel 293
Kim Abercrombie 295
Kim Abercrombie 2170
Kim Abercrombie 38
Hazem Abolrous 211
Sam Abolrous 2357
Humberto Acevedo 297
Gustavo Achong 291
Pilar Ackerman 299
按升序排序
USE [AdventureWorks2014] --Database Name
Select top 10 [FirstName], [LastName], [BusinessEntityID]
From [AdventureWorks2014].[Person].[Person]
Order By [BusinessEntityID] ASC
结果:
FirstName LastName BusinessEntityID
-------------------- ------------------- ----------------
Ken Sánchez 1
Terri Duffy 2
Roberto Tamburello 3
Rob Walters 4
Gail Erickson 5
Jossef Goldberg 6
Dylan Miller 7
Diane Margheim 8
Gigi Matthew 9
Michael Raheem 10
答案 0 :(得分:2)
猜猜你想要前10个姓氏,所以你可以这样做:
ConcurrentDictionary<Guid, ClientCallbackInfo>
答案 1 :(得分:1)
删除TOP 10
并添加WHERE
USE [AdventureWorks2014] --Database Name
Select [FirstName], [LastName], [BusinessEntityID]
From [AdventureWorks2014].[Person].[Person]
Where [BusinessEntityID] between 38 and 2357
Order By [BusinessEntityID] ASC
答案 2 :(得分:0)
你也可以使用这个
USE [AdventureWorks2014] - 数据库名称
选择前10名[FirstName],[LastName],[BusinessEntityID]
来自[AdventureWorks2014]。[Person]。[Person] WHERE [BusinessEntityID]&gt; = 38 AND [BusinessEntityID]&lt; = 2357
按[BusinessEntityID] ASC订购