【Oracle 结论】 
order by colum asc 时,null默认被放在最后
order by colum desc 时,null默认被放在最前
nulls first 时,强制null放在最前,不为null的按声明顺序[asc|desc]进行排序
nulls last 时,强制null放在最后,不为null的按声明顺序[asc|desc]进行排序 
【MySql 结论】
order by colum asc 时,null默认被放在最前
order by colum desc 时,null默认被放在最后
ORDER BY IF(ISNULL(update_date),0,1) null被强制放在最前,不为null的按声明顺序[asc|desc]进行排序
ORDER BY IF(ISNULL(update_date),1,0) null被强制放在最后,不为null的按声明顺序[asc|desc]进行排序

<select id="getPchsOrderReport" parameterClass="java.util.Map" resultClass="com.project.pojo.purchase.SupPurReport">
SELECT s.unit_uid as supplierId,s.UNIT_NAME as supplierName,IFNULL(m.orderNum, 0) as orderNum,IFNULL(m.orderPrice, 0) as orderPrice,
IFNULL(m.receiveNum, 0) as receiveNum ,IFNULL(m.receivePrice, 0) as receivePrice
FROM bas_supplier s LEFT JOIN (
SELECT
b.supplier_uid AS supplierId,
SUM(IFNULL(d.size, 0)) AS orderNum,
SUM(IFNULL(d.sum, 0)) AS orderPrice,
SUM(IFNULL(d.receive, 0)) AS receiveNum,
SUM(
IFNULL(d.receive, 0) * IFNULL(d.price, 0)
) AS receivePrice
FROM
pchs_bill b
LEFT JOIN pchs_detail d ON b.bill_uid = d.bill_uid
WHERE b.com_uid = #comUid#
<isNotEmpty property="status">
and b.status in <iterate property="status" conjunction="," close=")" open="(">#status[]:Integer#</iterate>
</isNotEmpty>
<isNotEmpty prepend="AND" property="startDate">
<![CDATA[b.bill_date >= #startDate#]]>
</isNotEmpty>
<isNotEmpty prepend="AND" property="endDate">
<![CDATA[b.bill_date <= #endDate#]]>
</isNotEmpty>
<isNotEmpty prepend="and" property="storageId"> b.storage_uid = #storageId# </isNotEmpty>
<isNotEmpty prepend=" and b.storage_uid in " property="multi_storage_uid">
<iterate property="multi_storage_uid" conjunction="," close=")" open="("> #multi_storage_uid[]# </iterate>
</isNotEmpty>
GROUP BY
b.supplier_uid
) m ON m.supplierId=s.unit_uid
<isNotEmpty property="supplierId">
WHERE s.unit_uid =#supplierId#
</isNotEmpty>
order by IF(ISNULL(orderNum),1,0),orderNum DESC,IF(ISNULL(orderPrice),1,0),orderPrice DESC
<isNotEmpty property="offset">
LIMIT #offset#,#limit#
</isNotEmpty>
</select>

  

order by 对null的处理的更多相关文章

  1. SQL - Order By如何处理NULL

    问题来了.执行SQL语句 SELECT * FROM tbl ORDER BY x, y 如果用来排序的列x.y当中有NULL值,那么它们的顺序是怎样的呢? 不同的数据库有不同的答案,目前的主流数据库 ...

  2. mysql 变量is null 和 not exists区别

    问题: 使用游标遍历时,发现使用 select var into tmp where var=? 然后判断if tmp is null时,不能走完所有的遍历.经debug发现, 当var为空时,则跳出 ...

  3. MySQL :: MySQL 8.0 Reference Manual :: B.6.4.3 Problems with NULL Values https://dev.mysql.com/doc/refman/8.0/en/problems-with-null.html

    MySQL :: MySQL 8.0 Reference Manual :: B.6.4.3 Problems with NULL Values https://dev.mysql.com/doc/r ...

  4. MySQL为何不建议使用null列

      Preface       Null is a special constraint of columns.The columns in table will be added null cons ...

  5. Null / Loopback (Null)

    参考: http://www.cnblogs.com/caoguoping100/p/3654452.html https://wiki.wireshark.org/NullLoopback 抓包安装 ...

  6. NULL-safe equal null 索引 空字符串

    小结 1. mysql> INSERT INTO my_table (phone) VALUES (NULL); 有手机号但是不知道 mysql> INSERT INTO my_table ...

  7. MVC5 网站开发之七 用户功能 2 用户添加和浏览

    目录 MVC5网站开发之一 总体概述 MVC5 网站开发之二 创建项目 MVC5 网站开发之三 数据存储层功能实现 MVC5 网站开发之四 业务逻辑层的架构和基本功能 MVC5 网站开发之五 展示层架 ...

  8. MVC5 网站开发之八 栏目功能 添加、修改和删除

    本次实现栏目的浏览.添加.修改和删除. 栏目一共有三种类型. 常规栏目-可以添加子栏目,也可以添加内容模型.当不选择内容模型时,不能添加内容. 单页栏目-栏目只有一个页面,可以设置视图. 链接栏目-栏 ...

  9. CJCMS系列--持久层对MangoDB的支持

    持久层添加对MangoDB数据库的支持 using System; using System.Collections.Generic; using System.Linq; using System. ...

随机推荐

  1. 关于profile集合

    profile集合是mongodb的慢操作日志 > db.getProfilingStatus() { , , } 可以通过getProfilingStatus来查看当前profile设置 pr ...

  2. C++手写快读详解(快速读入数字)

    众所周知,C++里是自带读入的(这不废话吗) 例如: int a; cin>>a; 这样的读入理解简单,适合初学者,但是非常慢. 再例如: int a; scanf("%d&qu ...

  3. 驾考试题的json代码

    { "statusCode": "000000", "desc": "请求成功", "result" ...

  4. AngularJS最佳实践

    1.依赖注入不要用推断式 2.双向绑定的变量设置成$scope下的一个对象的属性 3.多个控制器之间的通信尽量使用service实现,不要使用全局变量或者$rootScope 4.尽量不在控制器中操作 ...

  5. hibernate系列之一

    通过自己不断的学习框架以及相关知识的学习,自己学会总结了学习路上遇到的一些问题以及疑惑,自己现在跟着相关的学习资料又进行了一些总结和实践,希望通过自己走过的学习之路能够帮助小伙伴们解决一些学习上问题或 ...

  6. python 写 组合两两组合

    紧挨着 组合  a b c d  ----> ab ,bc ,cd portList = ['a', 'b', 'c', 'd'] for i, p in enumerate(portList) ...

  7. Aliyun ECS简单的安装nginx(1.8.0)

    1. yum install gcc-c++ 2. yum install -y pcre pcre-devel 3. yum install -y zlib zlib-devel 4. yum in ...

  8. 列举Asp.net页面之间传递值的几种方式和优缺点?

    一.QueryString变量 优点:使用简单,对于安全性要求不高时传递数字或是文本值非常有效. 缺点:缺乏安全性,由于它的值暴露在浏览器的URL地址中的:不能传递对象. 二. 使用Applicati ...

  9. html5定位获取当前位置并在百度地图上显示

    用html5的地理定位功能通过手机定位获取当前位置并在地图上居中显示出来,下面是百度地图API的使用过程,有需要的朋友可以参考下 在开发移动端 web 或者webapp时,使用百度地图 API 的过程 ...

  10. JZOJ 5455. 【NOIP2017提高A组冲刺11.6】拆网线

    455. [NOIP2017提高A组冲刺11.6]拆网线 (File IO): input:tree.in output:tree.out Time Limits: 1000 ms  Memory L ...