【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. 利用kvo实现列表倒计时

    自己稍微记录一下,方便以后用到: 先创建一个定时器的类: #import "TimeCenter.h" @interface TimeCenter () @property (no ...

  2. 将数据库数据显示到TreeView控件中

    实现效果: 知识运用: TreeView控件中的Nodes集合的Add方法 实现代码: private void init() { treeView1.ShowLines = true; treeVi ...

  3. JavaScript 交换两个变量的值

    方法一 let a = "a", b = "b"; console.log(a, b); let t = a; a = b; b = t; console.lo ...

  4. 可拖拽div

    在开发的时候需要一个可拖拽的prompt弹框.自己写了一个,大概思路为: 1.获取鼠标左键按下移动的起点坐标(x,y). 2.获取div的left和top属性. 3.得到鼠标坐标到左上角的距离(x-t ...

  5. ELFhash - 优秀的字符串哈希算法

    ELFhash - 优秀的字符串哈希算法 2016年10月29日 22:12:37 阅读数:6440更多 个人分类: 算法杂论算法精讲数据结构 所属专栏: 算法与数据结构   版权声明:本文为博主原创 ...

  6. RPC框架 - thrift 客户端

    -------客户端程序 ------ 下载    下载 thrift 源代码包    下载 thrift 的bin包 准备描述文件(使用源代码包的示例文件)    \thrift-0.10.0\tu ...

  7. php中处理字符串的常见函数

    编写程序的时候,经常要处理字符串,最基本就是字符串的查找,在php检测字符串中是否包含指定字符串可以使用正则,如果你对正则不了解,那么有几个函数可以为您提供方便. 1. strstr strstr() ...

  8. Cube HDU - 1220(思维)

    Cowl is good at solving math problems. One day a friend asked him such a question: You are given a c ...

  9. cf976f Minimal k-covering

    枚举 \(k\),对于每个点 \(i\) 我们最多删 \(deg_i-k\) 条边,就源点向第一部.第二部向汇点连边,容量是 \(deg_i-k\),原边连上,容量是 \(1\),这样每流过一条原边在 ...

  10. CSS中behavior属性语法简介

    本文和大家重点讨论一下CSS中behavior属性语法的使用,在进行CSS网页布局的时候,我们经遇到刷新要保留表单里内容的时候,习惯的做法使用cookie,但是那样做实在是很麻烦,CSS中的behav ...