从这句话:
df.rolling(window=3, min_periods=1, win_type='hanning').sum()
apple oranges pears
0 0.0 0.0 0.0
1 0.0 0.2 0.6
2 0.0 0.1 0.2
3 0.0 0.0 0.0
4 0.2 0.1 0.2
我收到以下错误:
SELECT a.comunity, sum(b.cont_woman),sum(b.cont_men) FROM cont_per_comunity.states_per_comunities a JOIN cont_per_comunity.cont_per_state b ON a.state = b.state WHERE sum(b.cont_woman) >= sum(b.cont_men) GROUP BY a.comunity;
有没有其他方法可以选择数据总和?
答案 0 :(得分:0)
您需要在having
子句或外部查询中执行此操作。您不能像在尝试的那样在where子句中使用聚合函数。
试试这个:
SELECT a.comunity, sum(b.cont_woman),sum(b.cont_men)
FROM cont_per_comunity.states_per_comunities a
JOIN cont_per_comunity.cont_per_state b
ON a.state = b.state
GROUP BY a.comunity
having sum(b.cont_woman) >= sum(b.cont_men)
或
select * from (
SELECT a.comunity, sum(b.cont_woman) as cont_woman
,sum(b.cont_men) as cont_men
FROM cont_per_comunity.states_per_comunities a
JOIN cont_per_comunity.cont_per_state b
ON a.state = b.state
GROUP BY a.comunity ) t
where cont_woman >= cont_men