Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
The Biggest Room1:22 with Ben Deitch
Which room has the largest capacity?
Wow, great job.
Also, while you're at it,
they'd like you to figure out which room seats the most people.
To figure out which room has the largest capacity, instead of using the sum or
count aggregate methods, we'll be using the MAX method.
So let's SELECT the MAX(CAPACITY) FROM the ROOMS table.
Then you Shift+Enter, and it looks like the MAX(CAPACITY) is 40.
And to figure out which room this is, we can just add in the ID column.
And if we run it now, it looks like it's room 19.
Also, another cool thing you can do is you can always just SELECT *.
You don't have to have * by itself, you can also use it with other columns.
So selecting * and the MAX(CAPACITY) will give us both the ID and
CAPACITY columns, and then the MAX(CAPACITY) columns.
Another thing to mention is that if we had more than one ROOM with the same CAPACITY,
which we don't in this example, but you might in a real-world scenario.
Then instead of doing this you might want to figure out the MAX(CAPACITY),
which is 40, and then SELECT everything from ROOMS
where the CAPACITY is equal to your MAX(CAPACITY).
Which in this example is just 19.
But again, if you had more than one room, you'd probably want to do it this way.
You need to sign up for Treehouse in order to download course files.Sign up