原文: MSSQL sql server order by 1,2 的具體含義 轉自:http://www.maomao365.com/?p=5416
摘要:
order by 1,2 的含義是對表的第一列 按照從小到大的順序進行排列
然後再對第二列按照從小到大的順序進行排列
order by 1,2 等同于 order by [第一列],[第二列]
詳見以下舉例說明
create table A (keyId varchar(20),name varchar(120))
go
insert into A (name,keyId)values(10,'we')
insert into A (name,keyId)values(2,'b')
insert into A (name,keyId)values(3,'C')
insert into A (name,keyId)values(4,'a')
insert into A (name,keyId)values(5,'E')
insert into A (name,keyId)values(7,'F')
go
select * from A
go
select * from A order by 1,2
go
truncate table A
drop table A
go