count(字段)不统计null值
来源:互联网 发布:mac迅雷没速度 编辑:程序博客网 时间:2024/05/29 03:17
在对有null值的字段进行count时,发现count(1)与count(字段)得到的记录不一样。
最后在ITPUB上朋友们的帮助下,解决了。
原帖地址:http://www.itpub.net/thread-1383832-1-2.html
结论:1.count(1)与count(*)得到的结果一致,包含null值。
2.count(字段)不计算null值
3.count(null)结果恒为0
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> desc t_product;
Name Type Nullable Default Comments
------------ ------------ -------- ------- --------
PRODUCT_ID NUMBER(6) Y
PRODUCT_NAME VARCHAR2(50) Y
LIST_PRICE NUMBER(8,2) Y
SQL> SELECT * FROM t_product WHERE list_price IS NULL;
PRODUCT_ID PRODUCT_NAME LIST_PRICE
---------- --------------- ----------
3355 HD 8GB /SI
1770 8MB Cache /NM
SQL> select count(1), count(*), count(list_price),count(null)
2 from t_product
3 where list_price is null;
COUNT(1) COUNT(*) COUNT(LIST_PRICE) COUNT(NULL)
---------- ---------- ----------------- -----------
2 2 0 0
- count(字段)不统计null值
- count(字段)不统计null值
- count(字段)不统计null值http://blog.csdn.net/lwei_998/article/details/6112810
- SQL:count(col)不统计col为null的行
- mysql 统计时 DISTINCT 的字段有 null值解决办法
- jackSon注解-- @JsonInclude 注解不返回null值字段
- 不重复数据字段统计
- COUNT(*)与COUNT(某个字段)的区别,及count(null)和count(distinct 某字段)的用法
- avg count null值计算
- mysql中查询字段为null或者不为null
- mysql中查询字段为null或者不为null
- mysql中查询字段替null或者不为null
- mysql中查询字段为null或者不为null
- mysql中查询字段为null或者不为null
- mysql中查询字段为null或者不为null
- mysql 需统计两个字段的和,当字段值为null不是整型的时候处理
- MyBatis在字段返回为null不返回字段
- MyBatis在字段返回为null不返回字段
- Linux下VirtualBox安装XP,U盘、U盾无法识别解决办法
- DI注解
- 自定义圆形进度条
- LightOJ 1400 - Employment【稳定婚姻问题】
- AV Foundation day by day-1
- count(字段)不统计null值
- 枚举定义
- AdaultBird--我的黑马程序员之路!Chapter12---面向对象的三大特性!
- Notes on Caffe layers
- 栈的入栈与出栈的序列
- leetcode add digits
- 排序方法性质总结
- Leetcode: H-Index II
- 自定义控件使用DrawableLeft/Right图片和文字同时居中