开发者

SQL : Group All

I want to do the following pseudo-SQL:

SUM( SELECT a FROM tab WHERE b > 0);

This syntax doesn't work (at least not in sqlite), so I'm trying to figure out the proper phrasing.

SELECT SUM(a) FROM tab WHERE b > 0 GROUP BY (*); % nope
SELECT SUM(a) FROM tab WHERE b > 0 GROUP BY开发者_如何学Go (1); % nope

Suggestions?


What's wrong with just SELECT SUM(a) FROM tab WHERE b > 0?


 SELECT SUM(a) FROM tab GROUP BY (b > 0) HAVING (b > 0);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜