Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql Hive中的高效子查询_Mysql_Hadoop_Hive_Hiveql - Fatal编程技术网

Mysql Hive中的高效子查询

Mysql Hive中的高效子查询,mysql,hadoop,hive,hiveql,Mysql,Hadoop,Hive,Hiveql,我有一张桌子- Employee Dept Visited 1 a yes 1 yes 1 yes 2 b 1 b yes 2 yes 3 ab 4 ac yes 5 yes 5 yes 6 fe 6 7 ad yes 2 ad yes 3 a yes 3 c 6 yes 7 8 a yes 8 yes 9 fe ye

我有一张桌子-

Employee    Dept    Visited
1   a   yes
1       yes
1       yes
2   b
1   b   yes
2       yes
3   ab
4   ac  yes
5       yes
5       yes
6   fe
6   
7   ad  yes
2   ad  yes
3   a   yes
3   c
6       yes
7   
8   a   yes
8       yes
9   fe  yes
*

我需要找到2个部门中没有空值的所有员工 访问=是

*

我尝试在Hive中编写查询,并遵循-

select c.Employee 
from table c
where c.Employee NOT IN (select d.Employee from table d where Visited = 'Yes' and Dept = '' group by d.Employee having count(d.Employee) >=2)
;
它是有效的,但是这个查询需要大量的时间,所以我相信它会更好。
任何建议

我建议使用
have
group by

select c.Employee
from table c
group by c.Employee
having sum(case when c.dept is null and c.visited = 'Yes' then 1 else 0 end) < 2;
选择c.员工
来自表c
按c.雇员分组
求和(c.dept为空,c.visitored为“是”,则为1,否则为0结束)小于2;

感谢您的查询,但我在更新的问题中遗漏了一个关键点,那就是找到没有空值的用户mentioned@ABC . . . 这实际上是对查询的一个相对较小的更改——删除
where
并修改
have