FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
comp0034_SQL/simpsons_queries_solutions.sql at master · UCLComputerScience/comp0034_SQL · GitHub
UCLComputerScience
comp0034_SQL
Repository navigation
Code
Issues
Pull requests
2
(2)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
comp0034_SQL
/
simpsons_queries_solutions.sql
Copy path
More file actions
More file actions
Latest commit
History
History
History
18 lines (15 loc) · 598 Bytes
Breadcrumbs
comp0034_SQL
/
simpsons_queries_solutions.sql
Copy path
File metadata and controls
18 lines (15 loc) · 598 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
--
Write queries to answer the following questions:
--
1. What are the names of all teachers Bart has had?
SELECT DISTINCT
t
.
name
FROM
teachers t
JOIN
courses c
ON
c
.
teacher_id
=
t
.
id
JOIN
grades g
ON
g
.
course_id
=
c
.
id
JOIN
students s
ON
s
.
id
=
g
.
student_id
WHERE
s
.
name
=
'
Bart
'
;
--
2. How many total students has Ms. Krabappel taught, and what are their names?
SELECT DISTINCT
s
.
name
FROM
students s
JOIN
grades g
ON
s
.
id
=
g
.
student_id
JOIN
courses c
ON
g
.
course_id
=
c
.
id
JOIN
teachers t
ON
t
.
id
=
c
.
teacher_id
WHERE
t
.
name
=
'
Krabappel
'
;
Back
|
FazBrowse Home
|
New Git URL