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);
精彩评论