Commit 5ea36fba authored by Marine Marsal's avatar Marine Marsal
Browse files

Update VIEWS.sql

parent 9e7373dd
......@@ -70,27 +70,27 @@ CREATE OR REPLACE VIEW FilmsPopulaires AS
ORDER BY COUNT(ep.ref) DESC;
CREATE OR REPLACE VIEW DureeMaxEmpruntParAdherent AS
SELECT va.nom, va.login login, MAX(duree) dureeEmpruntMax
SELECT va.nom, va.login login, MAX(p.duree) dureeEmpruntMax
FROM VAdherent va JOIN Pret p ON p.adherent = va.login
GROUP BY va.nom, va.login
ORDER BY MAX(duree) DESC;
ORDER BY MAX(p.duree) DESC;
CREATE OR REPLACE VIEW DureeMoyenneEmpruntParAdherent AS
SELECT va.nom nom, va.login login, AVG(duree) dureeMoyenneEmprunt
SELECT va.nom nom, va.login login, AVG(p.duree) dureeMoyenneEmprunt
FROM VAdherent va JOIN Pret p ON p.adherent = va.login
GROUP BY va.nom, va.login
ORDER BY AVG(duree) DESC;
ORDER BY AVG(p.duree) DESC;
CREATE OR REPLACE VIEW DureeMaxEmpruntParRessource AS
SELECT r.titre, r.codeUnique codeUnique, MAX(duree) dureeEmpruntMax
SELECT r.titre, r.codeUnique codeUnique, MAX(p.duree) dureeEmpruntMax
FROM Ressource r JOIN Exemplaire e ON e.ressource = r.codeUnique JOIN ExemplairePret ep ON ep.ref = e.ref JOIN Pret p ON p.pretID = ep.pret
GROUP BY r.titre, r.codeUnique
ORDER BY MAX(duree) DESC;
ORDER BY MAX(p.duree) DESC;
CREATE OR REPLACE VIEW DureeMoyenneEmpruntParRessource AS
SELECT r.titre, r.codeUnique codeUnique, AVG(duree) dureeMoyenneEmprunt
SELECT r.titre, r.codeUnique codeUnique, AVG(p.duree) dureeMoyenneEmprunt
FROM Ressource r JOIN Exemplaire e ON e.ressource = r.codeUnique JOIN ExemplairePret ep ON ep.ref = e.ref JOIN Pret p ON p.pretID = ep.pret
GROUP BY r.titre, r.codeUnique
ORDER BY AVG(duree) DESC;
ORDER BY AVG(p.duree) DESC;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment