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 | |
| d.nome AS departamento, | |
| COUNT(e.id) AS quantidade_empregados, | |
| ROUND(COALESCE(AVG(e.salario), 0), 2) AS media_salarial, | |
| MAX(e.salario) AS maior_salario, | |
| MIN(e.salario) AS menor_salario | |
| FROM departamentos d | |
| LEFT JOIN empregados e ON d.id = e.departamento_id | |
| GROUP BY d.nome | |
| ORDER BY media_salarial DESC; |
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 1a | |
| SELECT | |
| sch.name AS school, | |
| st.enrolled_at AS day, | |
| COUNT(st.id) AS enrolled_students, | |
| SUM(c.price) AS total_enrollment_value | |
| FROM students st | |
| JOIN courses c ON st.course_id = c.id | |
| JOIN schools sch ON c.school_id = sch.id |