Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. 1)
  2. CREATE VIEW mes_infos AS
  3. SELECT * FROM employe E
  4. where E.nom=substring_index(user(),’@’,1);
  5.  
  6. 2)
  7. CREATE VIEW salaire_employe AS
  8. SELECT E.Nom,E.salaire
  9. FROM employe E
  10. LEFT JOIN employeDept ED ON ED.numEmploye = E.num
  11. where ED.deptId IN (SELECT D.deptId
  12. FROM departement D
  13. LEFT JOIN employes E ON E.num = D.directeur
  14. where E.nom=substring_index(user(),’@’,1))
  15. AND E.nom <> substring_index(user(),’@’,1)
  16.  
  17. 3) CREATE VIEW moyenne_salaire_departement AS
  18. SELECT AVG(E.salaire),D.nom FROM employes E
  19. LEFT JOIN employedept ED on E.Num = ED.NumEmploye
  20. LEFT JOIN departement D on ED.DeptId = D.DeptId
  21. group by D.DeptId;
  22.  
  23. 4) CREATE VIEW nb_employe_projet AS
  24. SELECT count(ED.NumEmploye),P.NomProjet
  25. FROM departement D
  26. LEFT JOIN employedept ED ON ED.deptId = D.deptId
  27. LEFT JOIN membreprojet MP ON MP.numemploye = ED.numemploye
  28. LEFT JOIN projet P ON P.ProjetId = MP.ProjetId
  29. LEFT JOIN employes E ON E.Num = D.directeur
  30. where E.nom=substring_index(user(),’@’,1)
  31. group by P.projetId;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement