What would be the equivalent Excel formula of this SQL query
SELECT SUM(a) FROM table WHERE b < 0;
A B
---- ----
1 0
2 -1
3 4
5 -3
>> 开发者_如何学Python7
Use the SUMIF
function.
=SUMIF(B:B,"<0",A:A)
use SUMIFS(a1:a4,b1:b4,"<0") if values in A1:B4 range
Given:
Row# A B
3 1 0
4 2 -1
5 3 4
6 5 -3
=SUMIF(B3:B6; "<0"; A3:A6)
精彩评论