-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChallenge4
More file actions
19 lines (19 loc) · 735 Bytes
/
Challenge4
File metadata and controls
19 lines (19 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
SELECT
e.department_id,
COUNT(e.id) AS cantidad_empleados,
AVG(DATE_DIFF(CURRENT_DATE(), e.birth_date, YEAR)) AS promedio_de_edad,
COUNTIF(e.gender = 'Male') AS cantidad_hombres,
COUNTIF(e.gender = 'Female') AS cantidad_mujeres,
COUNTIF(e.gender = 'Agender') AS cantidad_agenero,
COUNTIF(e.gender = 'Non-Binary') AS cantidad_no_binario,
COUNTIF(e.gender NOT IN ('Male', 'Female', 'Agender', 'Non-Binary')) AS cantidad_otro_genero,
COUNTIF(e.hire_date > DATE(j.removed_date)) AS contratados_post_remocion
FROM
`mh-latam-sandbox.Training_BQ.Employees` AS e
LEFT JOIN
`mh-latam-sandbox.Training_BQ.Jobs` AS j
ON e.job_title = j.job_title
GROUP BY
1
ORDER BY
cantidad_empleados DESC