SQL 表中记录查询排序随笔(sql server中order by使用方式小总结)

SQL 表中记录查询排序随笔(sql server中order by使用方式小总结),资源免费,大家分享!

跟DB打交道,用得最多的是查询

既然查询就会有查询记录排序问题

我一直通过order by来解决

order by常用的使用方式我就不提了

项目的需求千变万化

让我们看看下面几个怪排序需求

--先创建一个表

create table ai(

id int not null,

no varchar(10) not null

)

go

--往表中插入数据

insert into ai

select 105,'2'

union all

select 105,'1'

union all

select 103,'1'

union all

select 105,'4'

go

--查询效果如下:

select * from ai

go

id no

----------- ----------

105 2

105 1

103 1

105 4

i.

--要求的查询结果如下

--即要求no列的数据按'4','1','2'排列

id no

----------- ----------

105 4

你可能喜欢

  • Word中使用公式编辑器
  • word中插入表格使用菜单
  • 指针式万用表使用secret
  • 查询中统计记录数应使用函数
  • openacs+server的使用

SQL 表中记录查询排序随笔(sql server中order by使用方式小总结)相关文档

最新文档

返回顶部