【发布时间】:2016-12-19 06:36:28
【问题描述】:
所以我有这个由 3 列组成的查询。 第一:
Select c1, sum(c2), sum(c3)
from t
where c4 not in ('xxx')
Group by c1
然后我根据条件得到 sum(c2) 和 sum(c3)。
我只想对 sum(c3) 应用条件。 我该怎么做?
我在下面尝试过,但没有成功:
Select c1, sum(c2), ( select sum(c3) from t where c4 not in ('xxx')) as c3
from t
group by c1
有什么建议吗? 谢谢!
【问题讨论】:
标签: sql sum conditional-statements