【发布时间】:2021-11-04 20:03:30
【问题描述】:
我有一个类似这样的查询,它给出了每个产品和集群有多少家商店。
SELECT product,
cluster,
count(distinct shop_id) AS shops
FROM a
WHERE site = 1
GROUP BY 1, 2
但是,我想看看每个产品是否有其他商店具有相同的集群。所以,如果有其他商店(> 1)YES,如果没有(
product | other_shops
X Yes
Y No
我该怎么做?
【问题讨论】:
-
向我们展示一些示例表数据和预期结果 - 全部为格式化文本(不是图像)。即minimal reproducible example.
-
为什么集群不是结果的一部分?结果表应该有:product、cluster、other_shops?
标签: sql amazon-web-services amazon-athena