Escolar Documentos
Profissional Documentos
Cultura Documentos
2. Fornea o RA, nome e nota dos alunos com nota menor que 5 em BD em
2010.
SELECT a.RA, a.NOME, a.NOME
from HISTORICO h, ALUNOS a
where cod_disc='BD' and ano=2010 and nota <5 and a.RA=h.RA
4. Encontre o nome, endereo, cidade dos alunos e cdigo das disciplinas onde
os alunos tiveram nota menor que 5 em 2010.
SELECT a.nome, a.ENDERECO, a.CIDADE, h.COD_DISC
from ALUNOS a, HISTORICO h
where a.RA = h.RA and h.NOTA<5 and h.ano=2010
(select H.RA
from HISTORICO h, PROFESSORES p
where h.COD_PROF = p.COD_PROF
and p.nome like '%MARCOS%')
7. Fornea o histrico escolar do aluno de nome Alex, ou seja, seu RA, nome, a
lista de disciplinas que ele j cursou contendo o cdigo e nome da disciplina,
freqncia e nota e ano que o aluno a cursou.
select a.RA, a.NOME,
h.COD_DISC, d.NOME_DISC,
h.ANO, h.FREQUENCIA, h.NOTA
from HISTORICO h, ALUNOS a, DISCIPLINAS d
where a.RA = h.RA
and h.COD_DISC = d.COD_DISC
and a.NOME like '%ALEX%'
as tipo
9. Fornea o nome dos alunos que cursaram disciplinas com carga horria
menor que 60 horas, bem como os respectivos professores que as lecionaram.
select a.NOME, p.NOME
from ALUNOS a, DISCIPLINAS d, PROFESSORES p, HISTORICO h
where
a.RA = h.RA and
d.COD_DISC = h.COD_DISC and
p.COD_PROF = h.COD_PROF and
d.CARGA_HOR<60
10. Localize o nome dos professores que lecionaram matrias nas quais o
aluno Pedro Paulo Cunha foi reprovado. (nota < 5)
select p.NOME
from ALUNOS a, PROFESSORES p, HISTORICO h
where
a.RA = h.ra and
p.COD_PROF = h.COD_PROF and
upper(a.NOME) = 'PEDRO PAULO CUNHA' AND
h.NOTA<5
from ALUNOS a
where not exists (select Cod_disc
from PROFESSORES p, TURMA t
where p.COD_PROF = t.COD_PROF and
P.NOME like '%JOO%'
and Cod_disc not in (select cod_disc
from HISTORICO h
where a.RA = h.RA))
12. Encontre o Ra, nome e mdia das notas dos alunos que cursaram todas as
matrias lecionadas por professores de Campinas.
Select distinct A.RA, A.NOME, AVG(nota)
from ALUNOS A , HISTORICO h where A.RA= h.RA
not exists
(select Cod_disc
from PROFESSORES p, TURMA t
where p.CIDADE = 'CAMPINAS'and Cod_disc not in
(select cod_disc
from HISTORICO h
where A.RA = h.RA))
group by A.RA, A.NOME
and
13. Localize o RA e nome dos alunos com nota menor que qualquer uma das
notas do aluno de RA 20090121.
select a.RA,a.NOME
from ALUNOS a, HISTORICO h
where a.RA = h.RA and
h.NOTA <any
(select nota from HISTORICO where RA = 20090121)
16. Fornea o nome dos professores que somente lecionaram matrias com
carga horria foi inferior a 60 horas.
Select p.NOME
ALUNOS a
18. Fornea o RA e nota dos alunos com nota em BD em 2010 menor que a
mdia das notas na disciplina.
select a.NOME, h.NOTA
from
ALUNOS a , HISTORICO h
19. Encontre o cdigo e nome das disciplinas e media das notas por disciplina,
mostre apenas as disciplinas com mdia de notas maior que 5.0.
select d.COD_DISC, d.NOME_DISC, avg(nota)
from
where
DISCIPLINAS d, HISTORICO h
h.COD_DISC = d.COD_DISC
22. Fornea o cdigo das disciplinas com mdia menor que a mdia das notas
em BD.
Select cod_disc, AVG(nota)
from historico
group by cod_disc
having avg(nota) < all (select avg(nota)
from historico
where cod_disc = 'BD')
23. Fornea o nome dos professores que j lecionaram alguma disciplina para
o aluno de RA 5400001.
Select P.nome
from Professores P, historico h
where P.cod_prof = H.cod_prof and H.RA = 5400001
24. Encontre o nome das disciplinas com mdia de freqncia abaixo de 80%.
Select nome_disc
From Disciplinas D,Historico H
Where H.cod_disc = D.cod_disc
group by nome_disc, carga_hor
having avg(frequencia) < 0.8 * carga_horaria
Where A.RA = H.RA and ano = 2010 and nota < 6.0
group by A.Nome
having count(*) >= 2
30. Fornea o nome dos professores e cdigo das disciplinas lecionadas por
ele em 2010 e a media das notas por disciplina.
select p.NOME, h.COD_DISC, avg(h.NOTA)
from PROFESSORES p, HISTORICO h
where h.COD_PROF=p.COD_PROF and h.ANO = 2010
group by p.NOME, h.COD_DISC
Operaes Diversas
Agora, iremos fazer algumas atualizaes nas tabelas que criamos acima.
1. Insira seus dados no BD: tabela de alunos (seu nome, Ra, endereo,
cidade), tabela de histrico cursando BD em 2009 na turma A com o professor
= 4
update
set
HISTORICO
nota
= 10
update
HISTORICO
HISTORICO
where RA IN
(select RA from Alunos where nome='Jorge dos Santos');
delete from ALUNOS
where nome = 'Jorge dos Santos';