【发布时间】:2020-08-05 06:11:24
【问题描述】:
我在 select 语句的聚合函数中有一个 case 表达式,看起来像这样。
select person_id,
sum(case status = 'approved' then hours else 0.0 end) as hours
sum(case status = 'cancelled' then void_hrs else 0.0 end) as void_hrs
sum(case status = 'forwarded' then fwd_hrs else 0.0 end) as fwd_hrs
from table
现在,我如何检查是否所有案例都返回 0.0?这样我就可以在结果集中排除它?
【问题讨论】:
-
它可能“看起来”像这样,但它也必须非常不同,因为您提供的内容有语法错误,甚至无法编译。而且您可能只是复制了上一个问题中提供给您的代码。只是没有尝试!
标签: sql sql-server database group-by sql-server-2012