离职率
- Dimission Rate
- 衡量企业内部人力资源流动状况 的一个重要指标
该指标反映 企业对员工的吸引和满意情况 - 离职率过高
通常表明 企业的员工情绪较为波动、劳资关系存在较严重的矛盾、企业凝聚力低下… 会导致人力资源成本增加、组织的效率下降… - 离职率不是越低越好
在市场竞争中,保持一定的员工流动,有利于企业人才优胜劣汰,保持企业的活力和创新意识
计算公式
离
职
率
=
离
职
人
数
/
(
离
职
人
数
+
期
末
在
职
人
数
)
离职率=离职人数/(离职人数+期末在职人数)
离职率=离职人数/(离职人数+期末在职人数)
示例SQL(HIVE)
WITH
staff as (
SELECT 'a1' staff_id, '2019-01-01' hire_date, NULL departure_date UNION ALL
SELECT 'a2' staff_id, '2019-01-01' hire_date, '2020-03-01' departure_date UNION ALL
SELECT 'a3' staff_id, '2019-01-01' hire_date, '2021-02-28' departure_date UNION ALL
SELECT 'a6' staff_id, '2019-06-01' hire_date, NULL departure_date UNION ALL
SELECT 'a7' staff_id, '2019-06-01' hire_date, '2020-03-02' departure_date UNION ALL
SELECT 'a8' staff_id, '2019-07-01' hire_date, NULL departure_date UNION ALL
SELECT 'a9' staff_id, '2019-07-01' hire_date, '2020-03-02' departure_date UNION ALL
SELECT 'a10' staff_id, '2019-07-01' hire_date, '2020-03-02' departure_date UNION ALL
SELECT 'a11' staff_id, '2019-07-01' hire_date, '2020-03-02' departure_date UNION ALL
SELECT 'a12' staff_id, '2019-09-01' hire_date, '2020-03-02' departure_date UNION ALL
SELECT 'a13' staff_id, '2020-01-01' hire_date, NULL departure_date UNION ALL
SELECT 'a14' staff_id, '2020-03-01' hire_date, '2020-03-31' departure_date UNION ALL
SELECT 'a15' staff_id, '2020-04-11' hire_date, NULL departure_date UNION ALL
SELECT 'a18' staff_id, '2020-04-11' hire_date, '2021-02-28' departure_date UNION ALL
SELECT 'a19' staff_id, '2020-04-11' hire_date, NULL departure_date UNION ALL
SELECT 'a20' staff_id, '2020-04-11' hire_date, NULL departure_date UNION ALL
SELECT 'a21' staff_id, '2020-04-11' hire_date, '2021-08-31' departure_date UNION ALL
SELECT 'a22' staff_id, '2020-04-11' hire_date, '2021-08-31' departure_date UNION ALL
SELECT 'a23' staff_id, '2020-11-01' hire_date, '2021-08-31' departure_date UNION ALL
SELECT 'a24' staff_id, '2020-11-01' hire_date, NULL departure_date UNION ALL
SELECT 'a25' staff_id, '2020-11-01' hire_date, NULL departure_date UNION ALL
SELECT 'a26' staff_id, '2021-03-01' hire_date, NULL departure_date UNION ALL
SELECT 'a26' staff_id, '2021-03-01' hire_date, NULL departure_date UNION ALL
SELECT 'a26' staff_id, '2021-03-01' hire_date, NULL departure_date UNION ALL
SELECT 'a31' staff_id, '2021-06-01' hire_date, NULL departure_date UNION ALL
SELECT 'a31' staff_id, '2021-06-01' hire_date, NULL departure_date UNION ALL
SELECT 'a33' staff_id, '2021-08-01' hire_date, NULL departure_date UNION ALL
SELECT 'a34' staff_id, '2021-09-01' hire_date, NULL departure_date UNION ALL
SELECT 'a34' staff_id, '2021-09-01' hire_date, NULL departure_date UNION ALL
SELECT 'a34' staff_id, '2021-09-01' hire_date, NULL departure_date UNION ALL
SELECT 'a34' staff_id, '2021-09-01' hire_date, NULL departure_date UNION ALL
SELECT 'a34' staff_id, '2021-09-01' hire_date, NULL departure_date UNION ALL
SELECT 'a34' staff_id, '2021-09-01' hire_date, '2021-09-30' departure_date UNION ALL
SELECT 'a35' staff_id, '2021-10-01' hire_date, NULL departure_date UNION ALL
SELECT 'a36' staff_id, '2021-11-01' hire_date, NULL departure_date
),
t AS (
SELECT '2019-01' ym UNION ALL
SELECT '2019-02' ym UNION ALL
SELECT '2019-03' ym UNION ALL
SELECT '2019-04' ym UNION ALL
SELECT '2019-05' ym UNION ALL
SELECT '2019-06' ym UNION ALL
SELECT '2019-07' ym UNION ALL
SELECT '2019-08' ym UNION ALL
SELECT '2019-09' ym UNION ALL
SELECT '2019-10' ym UNION ALL
SELECT '2019-11' ym UNION ALL
SELECT '2019-12' ym UNION ALL
SELECT '2020-01' ym UNION ALL
SELECT '2020-02' ym UNION ALL
SELECT '2020-03' ym UNION ALL
SELECT '2020-04' ym UNION ALL
SELECT '2020-05' ym UNION ALL
SELECT '2020-06' ym UNION ALL
SELECT '2020-07' ym UNION ALL
SELECT '2020-08' ym UNION ALL
SELECT '2020-09' ym UNION ALL
SELECT '2020-10' ym UNION ALL
SELECT '2020-11' ym UNION ALL
SELECT '2020-12' ym UNION ALL
SELECT '2021-01' ym UNION ALL
SELECT '2021-02' ym UNION ALL
SELECT '2021-03' ym UNION ALL
SELECT '2021-04' ym UNION ALL
SELECT '2021-05' ym UNION ALL
SELECT '2021-06' ym UNION ALL
SELECT '2021-07' ym UNION ALL
SELECT '2021-08' ym UNION ALL
SELECT '2021-09' ym UNION ALL
SELECT '2021-10' ym UNION ALL
SELECT '2021-11' ym UNION ALL
SELECT '2021-12' ym
),
h AS (
SELECT
SUBSTR(hire_date,0,7) ym,
COUNT(hire_date) c
FROM staff
GROUP BY SUBSTR(hire_date,0,7)
),
d AS (
SELECT
SUBSTR(departure_date,0,7) ym,
COUNT(departure_date) c
FROM staff
GROUP BY SUBSTR(departure_date,0,7)
),
staff_count_ym AS (
SELECT
t.ym ym,
NVL(h.c,0) hire_count,
NVL(d.c,0) departure_count
FROM t
LEFT JOIN h ON t.ym=h.ym
LEFT JOIN d ON t.ym=d.ym
),
staff_accumulation_ym AS (
SELECT
ym,
hire_count,
departure_count,
SUM(hire_count) OVER(
ORDER BY ym
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) hire_accumulation,
SUM(departure_count) OVER(
ORDER BY ym
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) departure_accumulation
FROM staff_count_ym
)
SELECT
ym,
hire_count,
departure_count,
hire_accumulation,
departure_accumulation,
hire_accumulation-departure_accumulation AS on_job_count,
departure_count/(departure_count+hire_accumulation-departure_accumulation) AS dimission_rate
FROM staff_accumulation_ym;
|