Você está na página 1de 1

NOME: Rodrigo Otavio Magalhães Salgado

Matr.: 201801140201

Trabalho de Projeto e Otimização de Banco de dados

A)
Select CodD, NomeD
From Disciplina
where CargaD between 3 and 5 and AreaD <> 'Saúde'

B)
select distinct NomeD
from Disciplina d
join Grade g on g.CodD = d.CodD
join Professor p on p.CodP = g.CodP
where CargaD < 5 and p.TituloP = 'Doutor'

C)
select distinct Sala
from Grade g
join Curso c on c.CodC = g.CodC
join Disciplina d on d.CodD = g.CodD
join Professor p on p.CodP = g.CodP
where c.DuracaoC > 3
and (d.AreaD is null or d.AreaD not in ('Matemática', 'Saúde', 'Humanas'))
and p.NomeP in ('Paulo', 'Joaquim', 'Juliana')

D)
select NomeP
from Professor p
where not exists (select CodP from Grade g where g.CodP = p.CodP)

E)
select d.NomeD, pre.NomeD
from Disciplina d join Disciplina pre on pre.CodD = d.PreReqD

F)
select NomeD from Disciplina
where CargaD > (select MAX(CargaD)
from Disciplina where AreaD = 'Matemática')

G)
select d.CodD,
count(distinct g.CodC) as CtCursos
from Disciplina d left join Grade g on g.CodD = d.CodD group by d.CodD

H)
select AVG(CargaD) as AvgCarga
from Disciplina
group by AreaD having AVG(CargaD) >= 3

I)
select d.NomeD
from Disciplina d
where d.PreReqD is null and not exists (select CodD from Disciplina d2 where d2.PreReqD = d.CodD)

J)
select c.NomeC from Curso c
where c.DuracaoC = (select c2.DuracaoC from Curso c2 where c2.NomeC = 'Eng Elétrica')
and c.MensC > (select c2.MensC from Curso c2 where c2.NomeC = 'Eng Elétrica')
and c.NomeC <> 'Eng Elétrica'

Você também pode gostar