【发布时间】:2020-01-27 14:03:28
【问题描述】:
我从 PostgreSQL 收到“不能嵌套聚合函数调用”错误。我尝试了很多不同的东西,但无法解决。
select c.*, (
select sum((count(distinct product_id))/2)
from page_views
where product_id in (c.p1, c.p2)
group by user_id, session_id
having count(distinct product_id) > 1
) freq
from (
select a.product_id p1, b.product_id p2
from (select distinct product_id from page_views) a,
(select distinct product_id from page_views ) b
where a.product_id <> b.product_id
) c ;
谢谢!
【问题讨论】:
-
请解释您要做什么。无法正常运行的 SQL 不一定能很好地解释意图。
-
请Edit您的问题并添加一些示例数据和基于该数据的预期输出。 Formatted text 请no screen shots
标签: sql postgresql