Last active
March 31, 2025 22:12
-
-
Save pedrosteinmuller/ef3f5df8c8f4c3a793541ba8e127956b to your computer and use it in GitHub Desktop.
Lia - Junior Data Analyst - Teste técnico - SQL - Questão 2 - Candidato Pedro Steinmuller Pimentel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| dp.nome as nome_departamento, | |
| COUNT(emp.matr) as quantidade_empregados, | |
| ROUND(COALESCE(AVG(venc.valor), 0), 2) as media_salario, | |
| ROUND(COALESCE(MAX(venc.valor), 0), 2) as maior_salario, | |
| ROUND(COALESCE(MIN(venc.valor), 0), 2) as menor_salario | |
| FROM public.departamento AS dp | |
| JOIN empregado AS emp ON dp.cod_dep = emp.gerencia_cod_dep | |
| JOIN emp_venc AS empv ON emp.matr = empv.matr | |
| JOIN vencimento as venc ON empv.cod_venc = venc.cod_venc | |
| GROUP BY dp.nome | |
| ORDER BY media_salario DESC; |
Author
pedrosteinmuller
commented
Mar 31, 2025

Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment