Skip to content

Instantly share code, notes, and snippets.

@SergioRodrigues1
Created March 29, 2025 15:59
Show Gist options
  • Save SergioRodrigues1/577ccee9efcd9a72e1f02f34b235eedc to your computer and use it in GitHub Desktop.
Save SergioRodrigues1/577ccee9efcd9a72e1f02f34b235eedc to your computer and use it in GitHub Desktop.
TESTE SQL - QUESTÃO 2 - LIA
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