mssql sqlserver order by 1具有什么功能呢?


摘要:
下文通过举例的方式讲述order by 1的具体含义,如下所示:
实验环境:sql server 2008 R2



order by 1功能说明

ORDER BY 1功能:
根据select 第一个字段进行排序操作
order by 1 asc :
根据select 第一个字段进行升序操作
order by 1 desc :
根据select 第一个字段进行降序操作



order by 1 举例说明

 create table [maomao365.com] (keyId varchar(20),name varchar(120))
go
insert into  [maomao365.com] (name,keyId)values(10,'we')
insert into  [maomao365.com](name,keyId)values(2,'b')
insert into  [maomao365.com](name,keyId)values(3,'C')
insert into  [maomao365.com] (name,keyId)values(4,'a')
insert into  [maomao365.com] (name,keyId)values(5,'E')
insert into  [maomao365.com] (name,keyId)values(7,'F')
go
select * from  [maomao365.com]
go
select * from  [maomao365.com] order by  1 desc  
go
truncate table  [maomao365.com]
drop table   [maomao365.com]
go 
order by 1用法举例

order by 1用法举例