OK so next up we're going to continue on with two new functions and they go together.
They fit well they're min and max minimum and maximum and they do what they sound like with their name
says they help you find and identify minimum values in a table or maximum values in a table and we can
use them on their own and we can also combine them with Group By to get further insights.
So we're going to see how to do both.
We're going to start off by using min and max without GROUP BY.
So we can do things like find the minimum release year in our entire table so you know what was the
first year any book was released.
And to do that just looks like this select men release year in parentheses from books.
So just like we did with the count where you could just count all the books if you wanted to you can
just use men on its own.
So let me show you how to do that.
Now go over to cloud nine and we can just do a select men released year from books.
And 19:45 is the earliest book that we have released the earliest years that a book was released.
We can also do something like select man pages if you want to see what's the shortest number of pages.
And that's that tells us 176 is the shortest.
So of course maximum works the same way.
So instead of men we just type Max and my X and does the same thing.
So here we're finding that while it doesn't do the same thing it works in the same way but it does the
exact opposite.
It's going to tell us or return the longest or the highest number of pages.
So if we do that I'll just recall that last line and just change it to be Max
634.
That is our longest book and we can do the same thing with year if we wanted to
2017 is our most recent years the highest number year.
So that's the very basics of maximun minute Max have you on say it.
I do want to call your attention to something sort of weird.
What if I wanted to get the title of the longest book not just the number of pages like we have here.
Just finding out that 634 is a longest.
Isn't that useful.
What if I wanted to know what is the book What's the title.
Who wrote it.
The year is released.
Any other information.
Well you might think you could do this.
Select max page is common title from books and if we try it out select max pages common title from books
it says that the namesake is our longest book and it has 634 pages.
And while yes 634 is the maximum pages in our entire database The Namesake is not 634 pages.
And in fact if we just do a select and let's just do title comic pages from books if we find the namesake
you'll see that it's 291 pages and the one that is 634 is the Amazing Adventures of Kavalier and Clay.
So that's a problem.
Here's a nice slow graphic.
It's the largest emoji that I can make and these slides for some reason.
So I'm just going to go ahead and insert a much larger one now.
Postproduction very fancy.
So how how do we get around this.
There has to be a way.
In fact there's multiple ways in the next video.
It's a bit of a cliffhanger here and the next video we're going to see a couple options including a
preview of a more advanced method something that we haven't seen just yet but there is a way to do it
using what we already know.
Something we learned a couple of videos ago.
All right.
Next video.