Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
How many students are in each grade? And how many 6th graders do you think they'll have next year?
-
0:00
Perfect, that`s just what they were looking for.
-
0:02
Also, usually you'd get to go home early on your second day.
-
0:06
But unfortunately they just got a call from the fire department and
-
0:09
they`re worried about the school`s capacity numbers.
-
0:11
They`re fine for this year but
-
0:13
the fire department thinks it`s possible there will be too many students next year.
-
0:18
Could you find out how many students are in each grade?
-
0:20
And then use that data to predict how many sixth graders they'll have next year?
-
0:25
To figure out how many students are in each grade,
-
0:28
we'll need to use our first GROUP BY clause.
-
0:30
So let's start by selecting everything from STUDENTS.
-
0:37
And luckily we've got a GRADE column.
-
0:39
So let's GROUP BY GRADE.
-
0:43
And let's change from selecting everything to counting what we
-
0:48
get in the results as well as telling us which grade is selected.
-
0:53
So let's do GRADE, COUNT1), or COUNT(*) or whatever count you feel like using.
-
0:57
And if we run this, there we go.
-
1:01
So now we need to figure out how many sixth graders they'll have next year.
-
1:04
Okay, so from grade 8 to 7, it looks like this goes up 24 students.
-
1:11
And then from 7 to 6, that's 27 students.
-
1:18
So 24 to 27.
-
1:21
And then maybe the next sixth graders will be plus 30, so
-
1:25
let's say that the next sixth grade class is probably gonna have about 220 students.
You need to sign up for Treehouse in order to download course files.
Sign up