Download answer_key/kpis/annual_attrition.sql from misatadata/pepperwind: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/datasets/misatadata/pepperwind/resolve/main/answer_key/kpis/annual_attrition.sql
- Command line
-
hf download hf://datasets/misatadata/pepperwind/answer_key/kpis/annual_attrition.sql
-
curl -L -o annual_attrition.sql https://huggingface.co/datasets/misatadata/pepperwind/resolve/main/answer_key/kpis/annual_attrition.sql
1.09 kB
| -- Attrition by fiscal year (April to March) | |
| -- Leavers in the fiscal year (or its part inside the window) over the mean month-end headcount in it. | |
| WITH m AS (SELECT strftime(range, '%Y-%m') AS month, range AS t0, range + INTERVAL 1 MONTH AS t FROM range(TIMESTAMP '2023-10-01', TIMESTAMP '2026-10-01', INTERVAL 1 MONTH)), fy AS (SELECT 'FY' || lpad(((CASE WHEN month(m.t0) >= 4 THEN year(m.t0) ELSE year(m.t0) - 1 END + 1) % 100)::VARCHAR, 2, '0') AS grp, (SELECT count(*) FROM core.employee e WHERE e.hire_date < m.t AND (e.leave_date IS NULL OR e.leave_date >= m.t)) AS hc FROM m), l AS (SELECT 'FY' || lpad(((CASE WHEN month(leave_date) >= 4 THEN year(leave_date) ELSE year(leave_date) - 1 END + 1) % 100)::VARCHAR, 2, '0') AS grp, count(*) AS leavers FROM core.employee WHERE leave_date IS NOT NULL AND leave_date >= TIMESTAMP '2023-10-01' AND leave_date < TIMESTAMP '2026-10-01' GROUP BY 1) SELECT fy.grp, coalesce(max(l.leavers), 0) AS leavers, avg(fy.hc) AS avg_headcount, coalesce(max(l.leavers), 0) / avg(fy.hc) AS value FROM fy LEFT JOIN l USING (grp) GROUP BY 1 ORDER BY 1 | |