exists ,not exists改写成in 和 not in 时,要注意null值的情况,会影响结果
2015-08-30 12:54
471 查看
---not exists
select count(distinct a.pos_mer_id)
from tests a
where a.stat_flag='C' and not exists
(select 1 from
hfods.tests b
where b.stat_flag='N' and b.pos_mer_id=a.pos_mer_id);
改写成not in
select count(distinct a.pos_mer_id)
from tests a
where a.stat_flag='C' and a.pos_mer_id not in
(select b.pos_mer_id from
tests b
where b.stat_flag='N' and b.pos_mer_id is not null)
select count(distinct a.pos_mer_id)
from tests a
where a.stat_flag='C' and not exists
(select 1 from
hfods.tests b
where b.stat_flag='N' and b.pos_mer_id=a.pos_mer_id);
改写成not in
select count(distinct a.pos_mer_id)
from tests a
where a.stat_flag='C' and a.pos_mer_id not in
(select b.pos_mer_id from
tests b
where b.stat_flag='N' and b.pos_mer_id is not null)
相关文章推荐
- CAS和Shiro在spring中集成
- CAS搭建单点登陆服务端配置
- CAS 统一认证服务器及应用
- CAS单点登录(一):CAS服务端
- Maven 教程
- Java面向切面编程(AOP模式)
- Java笔记——面向切面编程(AOP模式)
- https://projecteuler.net/archives
- coderbyte
- 关于如何根据几何网络进行爆管分析
- java读取properties文件
- Android笔记三(网络技术)
- Windows消息ID说明
- android 常见分辨率(mdpi、hdpi 、xhdpi、xxhdpi )及屏幕适配注意事项
- Linux系统--Linux磁盘和文件系统管理
- SpringMVC基础-@RequestMapping
- SVN图形化界面工具Cornerstone的管理项目
- 控制输入法演示
- 从C++到JAVA
- 挑战这十七项编程 锻炼大脑并且提升能力