LISTA DE EXERCÍCIOS___PLSQL

839 palavras 4 páginas
TURMA: BANCO DE DADOS
DATA: 05/06/2015

LISTA DE EXERCÍCIOS – SQL (ACVA 8ª Semana)

1)Encontre o RA dos alunos com nota em BD em 2010 menor que 5 (obs: BD = código da disciplinas).

select RA from HISTORICO where COD_DISC in ( select COD_DISC, ANO, nota from HISTORICO where COD_DISC = 'BD' and ANO = 2010 and nota < 5 ) ;

2)Forneça o RA, nome e nota dos alunos com nota menor que 5 em BD em 2010.

select h.RA, a.nome, h.nota from ALUNOS a, HISTORICO h where a.RA = h.RA and h.COD_DISC in ( select h.COD_DISC, h.ANO, h.nota from h where h.COD_DISC = 'BD' and h.ANO = 2010 and h.nota < 5 );

3)Forneça o nome dos professores de BD em 2010.

select p.nome from PROFESSORES p, HISTORICO h where p.COD_PROF = h.COD_PROF and COD_DISC = in ( select h.COD_DISC, h.ANO from h where h.COD_DISC = 'BD' and h.ANO = 2010 ) ;

4)Encontre o nome, endereço, cidade dos alunos e código das disciplinas onde os alunos tiveram nota menor que 5 em 2010.

select a.nome, a.endereco, a.cidade, d.COD_DISC, h.nota from ALUNOS a, TURMA t, HISTORICO h where t.COD_DISC = h.COD_DISC and a.RA = h.RA and h.nota in ( select h.nota from h where h.nota < 5 ) and h.ANO in ( select h.ANO from h where h.ANO = 2010 );

5)Obtenha o nome e RA dos alunos do professor em 2010.

select a.nome, a.RA, p.nome, h.ANO from ALUNOS a, PROFESSORES p, HISTORICO h where a.RA = h.RA and a.RA = p.COD_PROF and h.ANO = 2010 ;

6)Localize o nome e RA dos alunos do professor JOSÉ em 2010 ou 2009 que tiveram aulas com o professor MARCOS em algum ano.

select a.nome, a.RA, p.nome, h.ANO, from ALUNOS a, PROFESSORES p , HISTORICO h where a.RA = h.RA and p.COD_PROF = h.COD_PROF and p.nome in ( select p.nome from p where p.nome = 'MARCOS' ); and h.ANO in ( select h.ANO from h where h.ANO between 2009 and 2010 ) as ANO_PROFESSOR, ( select p.nome from p where p.nome = 'JOSE' ) as NOME_PROFESSOR ;

7)Forneça o histórico escolar do aluno de nome Alex, ou seja, seu RA, nome, a

Relacionados