Advertisement
Avdluna

Consultas

Nov 30th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.01 KB | None | 0 0
  1. # Consulta 1
  2. create view alunos_projeto_ano2000(nome_aluno) as
  3.     select distinct(a.nome)
  4.        from aluno a
  5.        where extract(year from a.dt_nasc) = 2000 and cod_projeto is not null
  6.  
  7. select * from alunos_projeto_ano2000
  8.  
  9. # Consulta 2
  10. select prof.matricula,prof.nome, sum(proj.orcamento) as "ORCAMENTO_TOTAL"
  11.     from professor prof, projeto proj
  12.     where prof.matricula=proj.mat_professor and extract(year from proj.dt_inicio) < 2007
  13.     group by prof.matricula,prof.nome
  14.  
  15. # Consulta 3
  16. create view laboratorio_projetos2014 as
  17.     select distinct(l.nome)
  18.         from laboratorio l, laboratorio_projeto lp, projeto p
  19.         where l.codigo = lp.cod_laboratorio and p.codigo = lp.cod_projeto and extract(year from p.dt_fim) = 2014
  20.  
  21. select * from laboratorio_projetos2014
  22.  
  23. # Consulta 4
  24. select distinct(a.nome)
  25.     from aluno a, aluno_publicacao ap, publicacao p
  26.     where a.matricula = ap.mat_aluno and upper(nivel)='DOUTORADO' and extract(year from a.dt_nasc) between 1982 and 1992 and
  27.     p.ano = 2017
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement