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 room has the largest capacity?
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
Wow, great job.
0:00
Also, while you're at it,
0:01
they'd like you to figure out
which room seats the most people.
0:03
To figure out which room has the largest
capacity, instead of using the sum or
0:07
count aggregate methods,
we'll be using the MAX method.
0:11
So let's SELECT the MAX(CAPACITY) FROM
the ROOMS table.
0:15
Then you Shift+Enter, and
it looks like the MAX(CAPACITY) is 40.
0:23
And to figure out which room this is,
we can just add in the ID column.
0:27
And if we run it now,
it looks like it's room 19.
0:32
Also, another cool thing you can do
is you can always just SELECT *.
0:36
You don't have to have * by itself,
you can also use it with other columns.
0:41
So selecting * and the MAX(CAPACITY)
will give us both the ID and
0:45
CAPACITY columns, and
then the MAX(CAPACITY) columns.
0:51
Another thing to mention is that if we had
more than one ROOM with the same CAPACITY,
0:55
which we don't in this example, but
you might in a real-world scenario.
0:59
Then instead of doing this you might
want to figure out the MAX(CAPACITY),
1:03
which is 40, and
then SELECT everything from ROOMS
1:06
where the CAPACITY is equal
to your MAX(CAPACITY).
1:12
Which in this example is just 19.
1:16
But again, if you had more than one room,
you'd probably want to do it this way.
1:18
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