SQL:全部分组
我想做以下伪 SQL:
SUM( SELECT a FROM tab WHERE b > 0);
这种语法不起作用(至少在 sqlite 中不起作用),所以我试图找出正确的措辞。
SELECT SUM(a) FROM tab WHERE b > 0 GROUP BY (*); % nope
SELECT SUM(a) FROM tab WHERE b > 0 GROUP BY (1); % nope
建议?
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 (1); % nope
Suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅 SELECT SUM(a) FROM tab WHERE b > 有什么问题吗? 0?
What's wrong with just
SELECT SUM(a) FROM tab WHERE b > 0
?