这是 select * from table1 的输出,我对 count 函数有疑问...我想计算 NULL,为了做到这一点,正确的选项是这样做:
select count(*) from table1 where fecha_devolucion is null --> 这给了我正确的答案计数 1 但是如果我这样做:
select count(fecha_devolucion)
from table1
where fecha_devolucion is null --> this returns 0, why? Isn't the same syntax?
Run Code Online (Sandbox Code Playgroud)
从表中选择特定字段和 * 有什么区别?
从文档(http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions032.htm):
如果指定 expr,则 COUNT 返回 expr 不为空的行数。...
如果指定星号 (*),则此函数将返回所有行...
换句话说,COUNT(fecha_devolucion) 计算该列的非 NULL 值。COUNT(*) 计算总行数,无论值如何。
| 归档时间: |
|
| 查看次数: |
10989 次 |
| 最近记录: |