From 98e5daa8fa0d930c0bd2d2fbe009324deaec89bb Mon Sep 17 00:00:00 2001
From: Joel Cavat <jcavat@gmail.com>
Date: Tue, 24 May 2022 21:00:00 +0200
Subject: [PATCH] Update corr

---
 corrections/chapitre_05/conf.sql | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/corrections/chapitre_05/conf.sql b/corrections/chapitre_05/conf.sql
index 5100ed9..852714e 100644
--- a/corrections/chapitre_05/conf.sql
+++ b/corrections/chapitre_05/conf.sql
@@ -122,7 +122,7 @@ SELECT C.name, start_date, end_date,
 FROM Conference AS C;
 
 -- 15
-SELECT name, SUM(fees) AS total
+SELECT name, SUM(IFNULL(fees,0)) AS total
 FROM Conference AS C
 LEFT JOIN Participation AS P ON C.id_conference = P.id_conference
 GROUP BY C.id_conference
@@ -176,14 +176,29 @@ INNER JOIN Participation AS P ON C.id_conference = P.id_conference
 WHERE login LIKE "stregunna14";
 
 -- 20
-SELECT S.login, firstname, lastname, fees
+SELECT DISTINCT S.login, firstname, lastname, fees
 FROM Speaker AS S 
 INNER JOIN Participation AS P ON S.login = P.login
 WHERE fees = (
     SELECT MAX(fees) FROM Participation
 );
 
+
+
+
+
+
+
 -- 21
+SELECT Speaker.login, firstname, lastname
+FROM Speaker INNER JOIN Participation ON Speaker.login = Participation.login
+GROUP BY Speaker.login
+HAVING SUM(fees) = (SELECT MAX(SUM) FROM
+(SELECT login, SUM(fees) AS SUM
+FROM Participation
+GROUP BY login));
+
+
 SELECT S.login, firstname, lastname, SUM(fees) AS F
 FROM Speaker AS S 
 INNER JOIN Participation AS P ON S.login = P.login
@@ -194,6 +209,7 @@ HAVING F = (
     ) AS G
 );
 
+
 WITH GBY (login, firstname, lastname, sum) AS (
     SELECT S.login, firstname, lastname, SUM(fees) AS F
     FROM Speaker AS S 
@@ -227,7 +243,7 @@ WHERE login NOT IN (
 );
 
 -- 24
-SELECT substr(A.lastname,1,2) AS SUB, A.firstname, A.lastname, B.firstname, B.lastname 
+SELECT substr(A.lastname,1,2) AS SUB, A.login, A.firstname, A.lastname, B.login, B.firstname, B.lastname 
 FROM Visitor AS A 
 INNER JOIN Visitor AS B ON substr(A.lastname,1,2) = substr(B.lastname,1,2)
 WHERE A.login > B.login
-- 
GitLab