oracle not in 问题
来源:互联网 发布:mac rebel什么质地 编辑:程序博客网 时间:2024/05/17 23:30
写了个sql 语句 ,大概逻辑是这样: 查询 在8月份出现,在九月份没有出现 的 用户 。
很简单的语句,如下
select distinct e.assign_oper from eir_print_bill e where e.assign_time between to_date('2017-09-01 00:00:00', 'yyyy-MM-dd hh24:mi:ss') and to_date('2017-09-30 23:59:59', 'yyyy-MM-dd hh24:mi:ss') and e.assign_oper not in (select distinct epb.assign_oper from eir_print_bill epb where epb.assign_time between to_date('2017-08-01 00:00:00', 'yyyy-MM-dd hh24:mi:ss') and to_date('2017-08-31 23:59:59', 'yyyy-MM-dd hh24:mi:ss'));
查询的结果,空的 。
好吧,于是执行 前半部分,也就是八月份的 ,6条 数据 ; 后部分,也就是九月份的 ,4条数据 。
再理了一遍逻辑,完全没发现有什么问题 。陷入了困惑 ……
后来注意到: 后部分,也就是九月份的数据中有个值是 空的 ,于是试一下,去空值 。修改后语句如下:
select distinct e.assign_oper from eir_print_bill e where e.assign_time between to_date('2017-09-01 00:00:00', 'yyyy-MM-dd hh24:mi:ss') and to_date('2017-09-30 23:59:59', 'yyyy-MM-dd hh24:mi:ss') and e.assign_oper is not null and e.assign_oper not in (select distinct epb.assign_oper from eir_print_bill epb where epb.assign_time between to_date('2017-08-01 00:00:00', 'yyyy-MM-dd hh24:mi:ss') and to_date('2017-08-31 23:59:59', 'yyyy-MM-dd hh24:mi:ss') and epb.assign_oper is not null);
好了,正确的结果出来了 。
结论 :
not in 里面的值不能有 空值 。
阅读全文
0 0
- oracle not in 问题
- Oracle中NOT IN的问题
- oracle中not in(null)问题
- oracle中not in(null)问题
- oracle的 not in
- Oracle:in/Not in操作
- ORACLE 在not in中使用null的问题
- Oracle里not in 有关null处理的奇怪问题
- ORACLE 在not in中使用null的问题
- oracle 中not in 效率不高的问题
- ORACLE 在not in中使用null的问题
- oracle not in查不出任何数据问题
- oracle in,exists,not in,not exists
- oracle--in与not in 语句 关于空值问题记录
- 慎用Oracle的not in
- Oracle NULL 和 NOT IN
- oracle not in 查不出数据
- Oracle中 NOT IN 优化
- redis配置说明
- Android相关书籍
- hdu2586 how far away?(lca求距离)
- android sudio 如何获取Sha1(调试版和发布版)
- Ruby学习笔记(11)_Date&Time
- oracle not in 问题
- Swift 值类型和引用类型
- JS—实现元素上下左右移动
- 通信数据交换格式 RPC框架 订阅发布
- android系统镜像:boot.img kernel.img ramdisk.img system.img userdata.img cache.img recovery.img
- C# 中2,10,16进制及其ASCII码之间转化
- 上传多张图片的流程与思想
- ios-CFAbsoluteTimeGetCurrent和CACurrentMediaTime
- 算法工程师找工作笔试题总结1(达达-京东)