如何在PostgreSQL中计算空值? [英] How to count null values in postgresql?

查看:377
本文介绍了如何在PostgreSQL中计算空值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

select distinct "column" from table;

输出:

    column
1     0.0
2     [null]
3     1.0

但是当我尝试计算空值时

But when I try to count the null values

select count("column") from train where "column" is NULL;

给出的输出为0(零)

您能建议哪里出问题了吗?

Can you suggest where it's going wrong?

推荐答案

使用 count(*)

select count(*) from train where "column" is NULL;

count()以及任何其他参数计数非NULL值,因此如果 NULL ,则不存在。

count() with any other argument counts the non-NULL values, so there are none if "column" is NULL.

这篇关于如何在PostgreSQL中计算空值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆