[英]How can I use select count (distinct x) in order to count two values in the same table and get the the two distinct values in my output?
[英]How can i use a Count distinct values in SQL?
如何在SQL中执行以下操作:
select count(distinct(field))
from table
最后的结果不算空值吗?
例:
最终结果应为3,但显示为4(由于为空值)。
明确为空并不意味着NULL
,因为不计算在内。 让我假设这意味着一个空字符串, ''
。 如果是这样的话:
select count(distinct nullif(field, ''))
@Gordon Linoff给出的答案就是解决方案!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.