Skip to content
Snippets Groups Projects
Commit b503ff3b authored by stephane.malandai's avatar stephane.malandai
Browse files

Update 27 files

- /exercices/correction/serie5.pdf
- /exercices/correction/serie 6/21.sql
- /exercices/correction/serie 6/20.sql
- /exercices/correction/serie 6/22.sql
- /exercices/correction/serie 6/COM 4 5.sql
- /exercices/correction/serie 6/23.sql
- /exercices/correction/serie 6/5_et_6.sql
- /exercices/correction/serie 6/18.sql
- /exercices/correction/serie 6/24.sql
- /exercices/correction/serie 6/19.sql
- /exercices/correction/serie 6/4.sql
- /exercices/correction/serie 6/7.sql
- /exercices/correction/serie 6/2.sql
- /exercices/correction/serie 6/3.sql
- /exercices/correction/serie 6/1.sql
- /exercices/correction/serie 6/8.sql
- /exercices/correction/serie 6/9.sql
- /exercices/correction/serie 6/14.sql
- /exercices/correction/serie 6/conf.sql
- /exercices/correction/serie 6/15.sql
- /exercices/correction/serie 6/17.sql
- /exercices/correction/serie 6/16.sql
- /exercices/correction/serie 6/COM 1 2 3.sql
- /exercices/correction/serie 6/12.sql
- /exercices/correction/serie 6/13.sql
- /exercices/correction/serie 6/11.sql
- /exercices/correction/serie 6/10.sql
parent 124d2200
Branches
No related tags found
No related merge requests found
Showing
with 183 additions and 0 deletions
-- 1
SELECT V.login, firstname, lastname, loyalty_points
FROM Visitor as V
INNER JOIN Fidelity as F ON V.login = F.login
WHERE loyalty_points < 50;
\ No newline at end of file
-- 10
SELECT *
FROM Visitor
WHERE login NOT IN (SELECT login FROM Registration);
--ou
SELECT *
FROM Visitor
LEFT JOIN Registration ON Visitor.login = Registration.login
WHERE id_conference IS NULL;
-- 11
SELECT V.login, firstname, lastname, COUNT(id_conference)
FROM Visitor AS V
LEFT JOIN Registration AS R ON V.login = R.login
GROUP BY V.login;
\ No newline at end of file
-- 12
SELECT lastname, firstname, start_date, end_date, name
FROM Speaker AS S
INNER JOIN Stay AS ST ON S.login = ST.login
INNER JOIN Hotel AS H ON ST.id_hotel = H.id_hotel;
\ No newline at end of file
-- 13
SELECT T.title, COUNT(DISTINCT login)
FROM Topic AS T
LEFT JOIN Conference AS C ON T.title = C.title
LEFT JOIN Registration AS R ON C.id_conference = R.id_conference
GROUP BY T.title;
\ No newline at end of file
-- 14
SELECT C.name, start_date, end_date,
(
SELECT COUNT(R.login) FROM Registration AS R
WHERE C.id_conference = R.id_conference
) AS Visitors,
(
SELECT COUNT(P.login) FROM Participation AS P
WHERE C.id_conference = P.id_conference
) AS Speakers
FROM Conference AS C;
\ No newline at end of file
-- 15
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
ORDER BY total DESC;
\ No newline at end of file
-- 16
SELECT T.title, SUM(IFNULL(fees,0)) AS S
FROM Topic AS T LEFT JOIN Conference AS C ON T.title = C.title
LEFT JOIN Participation AS P ON C.id_conference = P.id_conference
GROUP BY T.title
HAVING S < 20000;
\ No newline at end of file
-- 17
SELECT S.login, firstname, lastname, COUNT(id_conference)
FROM Speaker AS S
LEFT JOIN Participation AS P ON S.login = P.login
GROUP BY S.login;
\ No newline at end of file
-- 18
SELECT login, firstname, lastname
FROM Speaker
WHERE NOT EXISTS (
SELECT *
FROM Participation
WHERE Participation.login = Speaker.login
);
SELECT login, firstname, lastname
FROM Speaker
WHERE login NOT IN (
SELECT login
FROM Participation
);
SELECT Speaker.login, firstname, lastname
FROM Speaker
LEFT JOIN Participation ON Speaker.login = Participation.login
WHERE Participation.login IS NULL;
SELECT Speaker.login, firstname, lastname
FROM Speaker
LEFT JOIN Participation ON Speaker.login = Participation.login
GROUP BY Speaker.login
HAVING COUNT(Participation.id_conference) = 0;
\ No newline at end of file
-- 19
SELECT DISTINCT T.title
FROM Topic AS T
INNER JOIN Conference AS C ON C.title = T.title
INNER JOIN Participation AS P ON C.id_conference = P.id_conference
WHERE login LIKE "stregunna14";
\ No newline at end of file
-- 2
SELECT V.login, firstname, lastname, loyalty_points
FROM Visitor as V
LEFT JOIN Fidelity as F ON V.login = F.login
WHERE IFNULL(loyalty_points,0) < 50 AND V.login LIKE "l%";
-- ou
SELECT V.login, firstname, lastname, loyalty_points
FROM Visitor as V
LEFT JOIN Fidelity as F ON V.login = F.login
WHERE (loyalty_points < 50 OR loyalty_points IS NULL) AND V.login GLOB "l*";
\ No newline at end of file
-- 20
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
);
\ No newline at end of file
-- 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
GROUP BY S.login
HAVING F = (
SELECT MAX(S) FROM (
SELECT SUM(fees) AS S FROM Participation GROUP BY login
) AS G
);
WITH GBY (login, firstname, lastname, sum) AS (
SELECT S.login, firstname, lastname, SUM(fees) AS F
FROM Speaker AS S
INNER JOIN Participation AS P ON S.login = P.login
GROUP BY S.login
)
SELECT login, firstname, lastname, sum
FROM GBY
WHERE sum = (SELECT MAX(sum) FROM GBY);
\ No newline at end of file
-- 22
SELECT COUNT(DISTINCT login)
FROM Participation
INNER JOIN Conference USING (id_conference)
WHERE strftime("%Y", start_date) = "2019";
\ No newline at end of file
-- 23
SELECT *
FROM Visitor
WHERE login NOT IN (
SELECT Visitor.login
FROM Visitor
INNER JOIN Registration USING (login)
INNER JOIN Conference USING (id_conference)
WHERE strftime("%Y", start_date) = "2019"
);
\ No newline at end of file
-- 24
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
ORDER BY SUB;
\ No newline at end of file
-- 3
SELECT firstname, lastname, loyalty_points
FROM Visitor as V
INNER JOIN Fidelity as F ON V.login = F.login;
-- 4
SELECT *
FROM Conference
WHERE title IN ("databases", "microservices");
-- ou
SELECT *
FROM Conference
WHERE title IS "databases" OR title IS "microservices";
\ No newline at end of file
-- 5
SELECT title
FROM Topic;
-- 6
SELECT DISTINCT title
FROM Conference;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment