Ignore CAD and CSAD departments, no workers

This commit is contained in:
2025-08-12 12:06:36 +02:00
parent 735250c4c7
commit 9a7059dcdf
2 changed files with 51 additions and 0 deletions

View File

@@ -26,3 +26,53 @@ DROP TABLE raw.performance_review_sub_scoring;
DROP TABLE raw.performance_review_total_scoring; DROP TABLE raw.performance_review_total_scoring;
DROP TABLE raw.positions; DROP TABLE raw.positions;
DROP TABLE raw.workers; DROP TABLE raw.workers;
Data quality checks:
-- Total worker count
SELECT count(*)
from clean.worker;
-- Active workers
SELECT count(*)
from clean.worker
where employment_exit_date is null;
-- Number of job change / position change records
WITH history_counts AS (
SELECT w.id, count(*) as history_count
from clean.worker w
left join clean.job_change jc on w.id = jc.worker_id
group by w.id
)
SELECT history_count, count(*)
from history_counts
group by history_count
order by history_count;
-- Years at the company
WITH yac AS (
SELECT
w.id,
EXTRACT('YEAR' FROM AGE(COALESCE(employment_exit_date, CURRENT_DATE), employment_start)) AS years_at_company
FROM clean.worker w
)
SELECT
yac.years_at_company,
COUNT(*)
FROM yac
GROUP BY yac.years_at_company
ORDER BY yac.years_at_company
-- Worker id's with < 0 years at company or > 60 years
WITH yac AS (
SELECT
w.id, w.worker_hris_id, w.employment_start, w.employment_exit_date,
EXTRACT('YEAR' FROM AGE(COALESCE(employment_exit_date, CURRENT_DATE), employment_start)) AS years_at_company
FROM clean.worker w
)
SELECT *
from yac
where years_at_company < 0 or years_at_company > 60;

View File

@@ -13,6 +13,7 @@ latest_departments as (
from {{ source('tap_spreadsheets_anywhere', 'departments') }} from {{ source('tap_spreadsheets_anywhere', 'departments') }}
) t ) t
where rn = 1 where rn = 1
and id not in ('CAD', 'CSAD')
), ),
department_tree as ( department_tree as (
-- Anchor: top-level department (parent_id is set to Sarens Group in the Excel) -- Anchor: top-level department (parent_id is set to Sarens Group in the Excel)