Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sbd-alg-2022
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
romain.moscheni
sbd-alg-2022
Commits
d17a4c7b
Commit
d17a4c7b
authored
2 years ago
by
Joel Cavat
Browse files
Options
Downloads
Patches
Plain Diff
Corr. chapt. 5
parent
532a4766
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
corrections/chapitre_05/conf.sql
+140
-0
140 additions, 0 deletions
corrections/chapitre_05/conf.sql
with
140 additions
and
0 deletions
corrections/chapitre_05/conf.sql
+
140
−
0
View file @
d17a4c7b
...
...
@@ -120,3 +120,143 @@ SELECT C.name, start_date, end_date,
WHERE
C
.
id_conference
=
P
.
id_conference
)
AS
Speakers
FROM
Conference
AS
C
;
-- 15
SELECT
name
,
SUM
(
fees
)
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
;
-- 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
;
-- 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
;
-- 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
;
-- 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"
;
-- 20
SELECT
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
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
);
-- 22
SELECT
COUNT
(
DISTINCT
login
)
FROM
Participation
INNER
JOIN
Conference
USING
(
id_conference
)
WHERE
strftime
(
"%Y"
,
start_date
)
=
"2019"
;
-- 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"
);
-- 24
SELECT
substr
(
A
.
lastname
,
1
,
2
)
AS
SUB
,
A
.
firstname
,
A
.
lastname
,
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
;
-- COMMANDES
-- 1
INSERT
INTO
Visitor
VALUES
(
'toto21'
,
'Di'
,
'Dju'
);
-- 2
INSERT
INTO
Fidelity
VALUES
(
'toto21'
,
50
);
-- 3
INSERT
INTO
Registration
SELECT
'toto21'
,
id_conference
FROM
Conference
WHERE
name
=
'CurryOn'
;
-- 4
UPDATE
Fidelity
SET
loyalty_points
=
loyalty_points
*
2
;
-- 5
INSERT
INTO
Fidelity
SELECT
login
,
50
FROM
Visitor
WHERE
login
NOT
IN
(
SELECT
login
FROM
Fidelity
);
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment