select
g.inc_day,
count(
case
when g.position_attr in ('一线', '二线') then g.emp_code
end
) as one_two_total,
count(
case
when g.position_attr = '三线' THEN g.emp_code
end
) as three_total,
count(
case
when g.position_attr = 'LOST_POS_ATTR_M' THEN g.emp_code
end
) as lost_pos,
count(g.emp_code) as full_total
from
(
SELECT
a.inc_day,
if(
b.position_attr is null,
'LOST_POS_ATTR_M',
b.position_attr
) as position_attr,
a.emp_code
FROM
ods_hrssgps.tt_clock_log a
LEFT JOIN gdl.tt_emp_info b on(
b.emp_code = a.emp_code
and b.inc_day = a.inc_day
)
where
a.RESERVE3 IN ('100', '200', '300')
and a.inc_day >= '20190101'
and b.inc_day <= '20190701'
) g
group by
g.inc_day;
hive下1.5亿数据统计数据
最新推荐文章于 2025-07-04 16:33:06 发布
本文介绍了一个复杂的SQL查询案例,用于统计不同岗位属性的员工数量,包括一线、二线、三线和丢失岗位属性的员工总数。该查询从时钟日志和员工信息表中联接获取数据,针对特定的保留条件和日期范围进行筛选。
504

被折叠的 条评论
为什么被折叠?



