[英]SQL sum function with where clause
I am using MsSQL and I want to add some values where some conditions are met. 我正在使用MsSQL,我想在满足某些条件的情况下添加一些值。 Is it possible to use WHERE clause in the sum() function?
是否可以在sum()函数中使用WHERE子句? Or is there an equivalent function to the excel SUMIF().
或者是excel SUMIF()的等效函数。
The SUM
aggregate will only operate on the result set constrained by the WHERE
clause. SUM
聚合仅对WHERE
子句约束的结果集进行操作。
In other words, yes, this is fine. 换句话说,是的,这很好。
SELECT SUM(days)
FROM myTable
WHERE something = another
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.