码迷,mamicode.com
首页 > 数据库 > 详细

SQL排序问题

时间:2016-09-22 12:59:50      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

 1 ‘‘按多个字段排序
 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排序问题

标签:

原文地址:http://www.cnblogs.com/slmdr9/p/5895769.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!