在配置单元中处理不支持的相关where子查询

7cjasjjr  于 2021-06-29  发布在  Hive
关注(0)|答案(1)|浏览(286)

我正在尝试找出一个解决方法,以解决hive不支持相关子查询的问题。最后,我一直在计算上个月每周数据中存在多少项,现在我想知道本周有多少项退出、返回或完全是新的。如果我可以使用where子查询也不难,但是我很难想到没有它的工作环境。

Select
count(distinct item)
From data
where item in (Select item from data where date <= ("2016-05-10"))
And date between "2016-05-01" and getdate()

任何帮助都会很好。谢谢您。

kt06eoxx

kt06eoxx1#

解决方法是左连接两个结果集,其中第二个结果集列为null。
ie公司

Select count (a.item) 
            from 
                (select distinct  item from data where date between "2016-05-01" and getdate()) a
            left join (Select distinct  item from data where date <=  ("2016-05-10")) b
            on a.item =b.item
            and b.item is null

相关问题