一般用top命令,它的排序原则是什么?

来源:百度知道 编辑:UC知道 时间:2024/06/17 04:05:42
select top 1 手机号1 from
(
select 手机号1 from 表1
union
select 手机号2 from 表2
) s
---------结果:13666598123

select top 2 手机号1 from
(
select 手机号1 from 表1
union
select 手机号2 from 表2
) s
----结果:13512355526
13566987744

请问:为什么top 1 与top 2,结果不一样?为什么top 2的结果不是这个?
13666598123
13566987744

没有索引和排序时是随机的,有排序子句时安排序子句顺序取,没有排序只有索引时按索引顺序提取记录

top 1 是查询 排序后的第一条记录。
top 2 是查询 排序后的前两条记录。
top N 是查询 排序后的前N条记录。

不用order by系统默认是写入时间升序排序,后插入的排在后面