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 | |
| dep.nome AS departamento, | |
| COUNT(DISTINCT emp.matr) AS qtd_empregados, | |
| ROUND(AVG(COALESCE(venc.valor, 0)), 2) AS media_salarial, | |
| ROUND(MAX(COALESCE(venc.valor, 0)), 2) AS maior_salario, | |
| ROUND(MIN(COALESCE(venc.valor, 0)), 2) AS menor_salario | |
| FROM | |
| departamento dep | |
| LEFT JOIN | |
| empregado emp ON dep.cod_dep = emp.gerencia_cod_dep |
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
| --Questão 1: Letra a | |
| SELECT | |
| sc.name as school_name, | |
| st.enrolled_at, | |
| COUNT(*) as students_count, | |
| SUM(c.price) as Total_value | |
| FROM students st | |
| JOIN courses C on st.course_id = c.id | |
| join schools sc on c.school_id = sc.id |