Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Counting Students1:01 with Ben Deitch
How many students do they have at Jefferson Middle School?
How about this?
How many total students are at the school?
For this report, we'll need to be using the students table,
and we'll need to be selecting a count of all the students.
And to do that, we'll type SELECT, then COUNT, and
usually you'll COUNT(*), and then FROM STUDENTS.
Then we can run the query and we have 512 students.
Another interesting thing to mention is this star here.
When you're doing a count over a table, it's perfectly fine to count everything,
but it's also perfectly fine to just count 1.
And so, if we use Shift+Enter here, we get the same answer.
Now using 1 or * doesn't really make any difference,
just know that you can use either or.
You could even use a 10, or even a column name.
So STUDENTS.FIRST_NAME and we'll always get the same count.
You need to sign up for Treehouse in order to download course files.Sign up