Created
March 29, 2025 15:59
-
-
Save SergioRodrigues1/577ccee9efcd9a72e1f02f34b235eedc to your computer and use it in GitHub Desktop.
TESTE SQL - QUESTÃO 2 - LIA
This file contains 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 | |
d.nome_departamento, | |
COUNT(e.id_empregado) AS quantidade_empregados, | |
ROUND(AVG(COALESCE(e.salario, 0)), 2) AS media_salarial, | |
MAX(e.salario) AS maior_salario, | |
MIN(e.salario) AS menor_salario | |
FROM | |
departamento d | |
LEFT JOIN | |
empregado e ON d.id_departamento = e.id_departamento | |
GROUP BY | |
d.nome_departamento | |
ORDER BY | |
media_salarial DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment