【发布时间】:2021-03-18 06:30:39
【问题描述】:
如何在一个值的数量大于另一个值的 postgresql 行中进行选择? 例如,我只需要选择推荐较大的那些:
换句话说:
create table t(id bigint, place text, opinion text);
insert into t values
(1, 'mnt', 'yes'),
(2, 'mnt', 'no'),
(3, 'mnt', 'no'),
(4, 'cod', 'yes'),
(5, 'cod', 'yes'),
(6, 'cod', 'yes'),
(7, 'qrw', 'yes'),
(8, 'qrw', 'no'),
(9, 'caf', 'no'),
(10, 'mnt', 'yes');
我试图按地点统计分组,意见
【问题讨论】:
-
你想要什么结果?你在说什么?
-
@GordonLinoff 我想获得那些推荐大于“不推荐”的行
-
什么是“更大”?你是说你想要“推荐”或“不推荐”还是更高的 id?还有什么?
标签: sql postgresql count aggregate-functions having-clause