在以下查询中,我一直收到错误id - thumbnail
3 - http://wwww....
我无法弄明白为什么我会得到这个错误。
[42803] ERROR: column "distributed_stats_storage_facebook_post.impressions" must appear in the GROUP BY clause or be used in an aggregate function
我认为这里的这一部分是错误源自的地方,但似乎是要求我按汇总函数分组?
WITH qualified_posts AS (
SELECT
platform_data_api_post.external_id,
platform_data_api_account.display_name
FROM platform_data_api_post
INNER JOIN platform_data_api_account
ON platform_data_api_account._id = platform_data_api_post.account_id
INNER JOIN platform_data_api_platform
ON platform_data_api_platform._id = platform_data_api_account.platform_id
INNER JOIN platform_data_api_post_type
ON platform_data_api_post_type._id = platform_data_api_post.post_type_id
INNER JOIN distributed_stats_storage_facebook_post
ON distributed_stats_storage_facebook_post.external_object_id = platform_data_api_post.external_id
WHERE platform_data_api_platform.name = 'facebook'
AND platform_data_api_post_type.name = 'shared_link'
AND platform_data_api_post.published >
(DATE_PART(epoch, DATEADD(day, -10, DATE_TRUNC('day', GETDATE())))) :: BIGINT
GROUP BY 1, 2
HAVING max(distributed_stats_storage_facebook_post.stories_by_action_type__share) > 0
AND max(distributed_stats_storage_facebook_post.consumptions_by_type__link_clicks) > 0
),
impressions_percentiles_by_page AS (
SELECT qualified_posts.external_id,
qualified_posts.display_name,
max(impressions) AS impressions,
ntile(20) over (PARTITION BY qualified_posts.display_name order by impressions) AS impressions_percentile
FROM distributed_stats_storage_facebook_post
INNER JOIN qualified_posts ON qualified_posts.external_id = distributed_stats_storage_facebook_post.external_object_id
WHERE distributed_stats_storage_facebook_post.external_object_id IN (qualified_posts.external_id)
GROUP BY 1, 2
)
SELECT * FROM impressions_percentiles_by_page;
对我来说更奇怪的是,当我使用我正在使用的不同指标推出impressions_percentiles_by_page AS (
SELECT qualified_posts.external_id,
qualified_posts.display_name,
max(impressions) AS impressions,
ntile(20) over (PARTITION BY qualified_posts.display_name order by impressions) AS impressions_percentile
FROM distributed_stats_storage_facebook_post
INNER JOIN qualified_posts ON qualified_posts.external_id = distributed_stats_storage_facebook_post.external_object_id
WHERE distributed_stats_storage_facebook_post.external_object_id IN (qualified_posts.external_id)
GROUP BY 1, 2
)
子句时。下面的完整查询工作正常。除了他们查询的列,这两个条款是相同的
impressions_percentiles_by_page