这里的第一篇文章。我正在尝试获取一个交易密钥列表,其中有14个左右的产品列表中的任何两个都已被购买。我已经尝试了下面这样的东西,但它给了我购买了两个产品的事务密钥,并且至少有一个在列表中:
create or replace temp table PIE_TRANS AS
select
case when sum(i.quantity) >=2 then i.transactionkey end as transactionkey
from ProductTable p
inner join Records i on p.productkey = i.productkey
where
P.SKU_NO in(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
and i.datekey between '20200101' and '20201001'它只是找出了正确的逻辑:/任何帮助都将不胜感激!
谢谢
发布于 2020-10-21 00:35:31
不是100%确定我理解所需的逻辑,但尝试一下。
create or replace temp table PIE_TRANS AS
select i.transactionkey
from ProductTable p
inner join Records i on p.productkey = i.productkey
where P.SKU_NO in(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
and i.datekey between '20200101' and '20201001'
group by i.transactionkey
having sum(i.quantity) >= 2https://stackoverflow.com/questions/64449372
复制相似问题