我想知道是否有可能最好使用PL/SQL V11上的select语句从这个表中获得以下结果:
Area Store Product
10 1 A
10 1 B
11 1 E
11 1 D
10 2 C
10 2 B
10 2 A
10 3 B
10 3 A
13 1 B
13 1 A
并返回此结果,因此它按区域分组、存储、查找、区域和存储相同的产品。所以第10区的商店1有产品A和B,所以它会查看只有A和B的其他商店的列表,并计算它们。在本例中,它计算区域10存储1 /区域10存储3/区域13存储1。
Product Count of groups
AB 3
ABC 1
DE 1
提前谢谢你的帮助。
发布于 2018-03-19 19:18:30
是的,您可以使用listagg()
,然后再使用另一个group by
select products, count(*)
from (select listagg(product) within group (order by product) as products
from t
group by area, store
) p
group by products;
https://stackoverflow.com/questions/49370687
复制相似问题