SQL排序问题
时间:2021-07-01 10:21:17
帮助过:4人阅读
‘‘按多个字段排序
2 Select * From Job
order by job
desc,id
asc
3
4 ‘‘按首字符(非数字)排序
5 Select * From Job
order by case when isnumeric(
left(jobno,
1))
=0
6 Then left(jobno,
1)
end
7
8 ‘‘按首字符分组
9 Select count(jobno)
From Job
group by left(jobno,
1)
10
11 ‘‘合并Order by排序语句
12 SELECT * FROM
13 (
Select TOP 200000 * From Job
Where jobno
not like ‘[0-9]%‘ order by Jobno
desc) A
14 UNION ALL
15 SELECT * FROM
16 (
Select TOP 200000 * From Job
Where jobno
like ‘[0-9]%‘ order by ID
desc) B
SQL排序问题
标签: