我正在试图找到的记录数,是独家不在零售商\u id 27,28,29。但此查询在配置单元中不起作用。你能告诉我哪里出错了吗。
在同一个表上尝试子查询,但似乎不起作用。
Select count(Distinct T.hhid)
from transactions
where hhid NOT IN (Select hhid
from transactions
where retailer_id IN (4,5,6,7,8,13,17,20,21,25,31)
and transaction_date between '2018-08-01' and '2019-07-31'
) as T
where T.retailer_id IN (27, 28, 29)
and transaction_date between '2018-08-01' and '2019-07-31'
ERROR : missing EOF at 'as' near ')'
如果你能在sparksql中提出一些同样适用于我的建议。
2条答案
按热度按时间piv4azn71#
您的查询在很多方面都没有意义:
这个
as T
最后是在错误的地方。你具体想做什么T
代表?你的两份名单
retailer_id
似乎是多余的。在一种情况下,您选择的记录retailer_id
IS NOT IN (4,5,6,7,8,13,17,20,21,25,31)
然后添加一个WHERE
声明retailer_id IS IN
(27, 28, 29)`. 为什么两者都有?我想你可能想重新开始,确定你的选择标准是什么,然后从那里开始。
7xllpg7q2#
尝试下面的脚本-