Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed SQL Reporting by Example!
You have completed SQL Reporting by Example!
Preview
Which teacher teaches 7th grade science?
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Great, he's just ordered
them all a fruit basket.
0:00
Also, the principal has been
hearing some really good things
0:03
about the new seventh
grade science teacher.
0:06
Can you figure out who teaches
seventh grade science so
0:08
he can get them a fruit basket too?
0:10
>> This query is gonna be
pretty similar to the last one.
0:13
So to make it seem a little different,
I'm going to do this from
0:16
the perspective of the subjects
table instead of the teachers table.
0:19
So let's start by selecting everything
from the subjects table and
0:23
then join to the classes table.
0:28
And we'll join it on SUBJECTS.ID
= CLASSES.SUBJECT_ID.
0:30
Then from here, we'll need to
0:37
JOIN TEACHERS ON TEACHERS.ID
= CLASSES.TEACHER_ID.
0:41
Then in the where clause we need to make
sure that we're only looking at seventh
0:49
grade science classes, and
that information is in the subjects table.
0:54
So WHERE, and
0:58
let's look in the subjects table to
see what those columns are called.
0:59
And so we're going to say subjects
name is equal to science.
1:03
And subject's grade is equal to seven.
1:08
So WHERE NAME = 'Science' AND
1:11
GRADE = 7.
1:19
And it looks like you need
to have a FROM keyword.
1:22
And thatβs true,
you need to have the FROM keyword.
1:25
And it needs to be before the table
that youβre selecting from.
1:30
And then just like the last table, we'll
wanna bring in the distinct keyword on
1:37
the ID, and select just the first and
last name columns.
1:41
And remember,
we wanna use the teacher's ID column and
1:44
then first name and
last name, and there we go.
1:49
Isabella Little is the 7th
grade science teacher.
1:54
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up