【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. ActiveX插件的Z-Index属性无效问题解决

    在Web开发中我们经常通过z-index设置多个元素之间的层叠关系,这种方式在多数情况下很有效,但是如果遇到有窗体元素时这种方式常常显得无能为力,今天我们就一块看一下如何有效的解决这个问题. 在Web ...

  2. linux用命令行运行matlab的.mat文件

    入m文件所在目录后,运行 $ matlab -nodesktop -nosplash -r matlabfile 只用文件名matlabfile,不能添加.m

  3. CUDA常见问题与解答

    源 1.在SDK自带的例子程序中,发现SRC文件珜下有.cpp文件和.cu文件.这两种文件的关系和各自的作用是什么呀? 答:SDK自带例子中的.cpp文件主要是一些CPU端处理,或者是使用CPU计算对 ...

  4. 在maven项目中 配置代理对象远程调用crm

    1 在maven项目中配置代理对象远程调用crm 1.1 在项目的pom.xml中引入CXF的依赖 <dependency> <groupId>org.apache.cxf&l ...

  5. 通过jQuery遍历div里面的checkbox

    遍历: $('#queryUser2 input[type="checkbox"]:checked').each( function () { a = a + $(this).va ...

  6. 谭浩强 c++程序设计第一章课后习题 第7题

    #include <iostream> using namespace std; int main() { int a,b,c; int f(int x,int y,int z);//这是 ...

  7. bat 服务启动脚本

    当电脑上有多个数据库(特别是Oracle,占用内存大,所以我都是设置为手动启动的,或者想在电脑上运行一下其他UI类软件或玩些游戏的时候也需要暂时关掉,奈何我这渣机(V_V))需要启动或停止的时候,就用 ...

  8. css清除浮动,清除子节点margin溢出问题

    清除浮动 .clearfix:after{ content:”.”; display:block; height:0; clear:both; visibility:hidden; } 清除margi ...

  9. winform中使用webBrowser时如何与JS交互

    最近写一个GEPlugin项目,要用到geWebBrowser与JS进行交互. 这个geWebBrowser的事件 private void geWebBrowser1_DocumentComplet ...

  10. 在F12 控制台输入,可执行jquery操作

    <!-- 控制台执行jquery -->var importJs=document.createElement('script') //在页面新建一个script标签importJs.se ...