在 POSTGRES 中返回每行的 COUNT,而不是总和或单行
我对此使用了变体:
SELECT (select count(active) AS true
from sooper_entry
where active = 't'
and entry_id_ref = 28) AS true,
(select count(active) AS false
from sooper_entry
where active = 'f'
and entry_id_ref = 28) AS false;
因此我可以获得所有 true 和 false 的计数,但我需要在关联数组中返回 true false 计数。
期望的结果:
true | false | uId
------+-------+-----
16 | 0 | 1
10 | 2 | 3
13 | 10 | 4
19 | 8 | 5
12 | 3 | 8
21 | 0 | 12
(6 rows)
I have used variations on this:
SELECT (select count(active) AS true
from sooper_entry
where active = 't'
and entry_id_ref = 28) AS true,
(select count(active) AS false
from sooper_entry
where active = 'f'
and entry_id_ref = 28) AS false;
So I can get a COUNT of all the true and false, but I need a true false count returned in an associative array.
desired result:
true | false | uId
------+-------+-----
16 | 0 | 1
10 | 2 | 3
13 | 10 | 4
19 | 8 | 5
12 | 3 | 8
21 | 0 | 12
(6 rows)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)