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
7977e5f6
Commit
7977e5f6
authored
2 years ago
by
Joel Cavat
Browse files
Options
Downloads
Patches
Plain Diff
Ten first queries
parent
4178e2b8
No related branches found
Branches containing commit
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
+90
-0
90 additions, 0 deletions
corrections/chapitre_05/conf.sql
with
90 additions
and
0 deletions
corrections/chapitre_05/conf.sql
0 → 100644
+
90
−
0
View file @
7977e5f6
-- 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
;
-- 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%"
;
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*"
;
-- 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"
);
SELECT
*
FROM
Conference
WHERE
title
<>
"databases"
OR
title
IS
"microservices"
;
-- 5
SELECT
title
FROM
Topic
;
-- 6
SELECT
DISTINCT
title
FROM
Conference
;
-- 7
-- non standard, sqlite only
SELECT
*
FROM
Visitor
INTERSECT
SELECT
*
FROM
Speaker
;
-- standard
SELECT
*
FROM
Visitor
INNER
JOIN
Speaker
ON
Visitor
.
login
=
Speaker
.
login
;
-- sous-requête IN
SELECT
*
FROM
Visitor
WHERE
login
IN
(
SELECT
login
FROM
Speaker
);
-- sous-requête EXISTS
SELECT
*
FROM
Visitor
WHERE
EXISTS
(
SELECT
login
FROM
Speaker
WHERE
Speaker
.
login
=
Visitor
.
login
);
-- 8
SELECT
*
FROM
Speaker
WHERE
login
NOT
IN
(
SELECT
login
FROM
Visitor
);
-- 9
SELECT
Topic
.
title
,
COUNT
(
id_conference
)
FROM
Topic
LEFT
JOIN
Conference
ON
Conference
.
title
=
Topic
.
title
GROUP
BY
Topic
.
title
;
-- 10
SELECT
*
FROM
Visitor
WHERE
login
NOT
IN
(
SELECT
login
FROM
Registration
);
SELECT
*
FROM
Visitor
LEFT
JOIN
Registration
ON
Visitor
.
login
=
Registration
.
login
WHERE
id_conference
IS
NULL
;
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