Oracle SQL 统计
Oracle中的 ‘空字符串’ 和 ‘NULL’ 的区别?
''
: ‘空字符串’
' '
:不是 ‘空字符串’ ,中间有空格;
‘空字符串’ 和 ‘NULL’ 不同。例如:where条件中 is null
和 =''
结果不一样。
我们无法将 ‘空字符串’ 存进 Oracle 数据库。
感觉有 ‘NULL’ 了,’空字符串’ 有点多余。
参考:
https://blog.csdn.net/weiwenhp/article/details/7035327
根据条件进行count
方法一:count 与 decode 连用
1 | select t.code, |
方法二:count 与 case when 连用,与方法一相比,可以进行条件判断(>、<、=)
count():列值为空或null,不计数,显示为0。
1 | select t.code, |
方法三:sum 与 decode 连用
sum():列值为空或null,不计数,显示为空或null。
1 | select t.code, |
方法四:sum 与 case when 连用
—参考方法二—。