首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当两个字段都为空时计数为空

当两个字段都为空时计数为空
EN

Stack Overflow用户
提问于 2021-06-18 19:08:48
回答 2查看 22关注 0票数 0

如何计算每个日期的null(当评论和卖家为null时)?

order_time不是日期/时间字段

所附图片上的数据示例解释了我在此尝试实现的目标

enter image description here

EN

回答 2

Stack Overflow用户

发布于 2021-06-18 19:10:26

如何计算每个日期的null(当评论和卖家为null时)?

想必,你想要这样的东西:

代码语言:javascript
复制
select date, sum(case when comment is null and seller is null then 1 else 0 end) as both_null
from t
group by date;
票数 0
EN

Stack Overflow用户

发布于 2021-06-18 19:19:03

在where子句的帮助下,选择在注释和卖方列中只有null的行。然后只需使用group by进行计数。我还将order_time列转换为date。

代码语言:javascript
复制
select cast(order_time as date) order_date, count(*) null_count
from yourtable
where comment is null and seller is null
group by  cast(order_time as date);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68034089

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档