HiveQL的计数总和

时间:2018-06-27 19:45:30

标签: sql hiveql

enter image description here enter image description here我是HiveQL的新手。这是我的问题。我有雇员解雇/退休,在重新雇用后同一时间段内同一雇员将有多个解雇,我需要计算总和(解雇)。下面是我的查询.. HiveQL

select employee_id, Date, work_dept_c, Emp_type, mlvl_n,
       (case when work_dept_c in (1,2,3,4,5) and emp_type not in ('S') and mlvl_n not in (T') then count(employee_id) else 0 end) as Countofemployee
from tablex
where date between '2018-01-01' and '2018-06-01'
group by work_dept_c, emp_type, mlvl_n, employee_id, date 

以上查询有效,并且给了我被终止雇员的数量,但是如果同一时间两次被解雇但又在同一时期再次被雇用的雇员,它并不能给我相同雇员的总和,基本上我需要得到2终止计数...我尝试放入Sum,但它不起作用...可以帮助您,如果我不清楚,请告诉我

0 个答案:

没有答案