Skip to content

Instantly share code, notes, and snippets.

View SergioRodrigues1's full-sized avatar

Sergio Augusto Rodrigues Moura SergioRodrigues1

View GitHub Profile
@SergioRodrigues1
SergioRodrigues1 / TesteSQL_QUESTAO_2.sql
Created March 29, 2025 15:59
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
@SergioRodrigues1
SergioRodrigues1 / TesteSQL_QUESTAO_1.sql
Created March 29, 2025 15:50
TESTE SQL - QUESTÃO 1 - LIA
-- **Parte A: Quantidade de alunos matriculados e valor total das matrículas**
SELECT
s.name AS school_name,
st.enrolled_at::date AS enrollment_date,
COUNT(st.id) AS total_students,
SUM(c.price) AS total_price
FROM
students st
JOIN
courses c ON st.course_id = c.id