WEBVTT

00:00.260 --> 00:06.550
OK so next up we're going to continue on with two new functions and they go together.

00:06.570 --> 00:12.220
They fit well they're min and max minimum and maximum and they do what they sound like with their name

00:12.220 --> 00:19.080
says they help you find and identify minimum values in a table or maximum values in a table and we can

00:19.080 --> 00:25.560
use them on their own and we can also combine them with Group By to get further insights.

00:25.590 --> 00:27.500
So we're going to see how to do both.

00:27.540 --> 00:31.820
We're going to start off by using min and max without GROUP BY.

00:32.050 --> 00:37.840
So we can do things like find the minimum release year in our entire table so you know what was the

00:37.840 --> 00:39.970
first year any book was released.

00:40.420 --> 00:49.170
And to do that just looks like this select men release year in parentheses from books.

00:49.240 --> 00:54.100
So just like we did with the count where you could just count all the books if you wanted to you can

00:54.100 --> 00:55.950
just use men on its own.

00:56.230 --> 00:57.250
So let me show you how to do that.

00:57.250 --> 01:08.780
Now go over to cloud nine and we can just do a select men released year from books.

01:10.350 --> 01:16.800
And 19:45 is the earliest book that we have released the earliest years that a book was released.

01:16.860 --> 01:24.960
We can also do something like select man pages if you want to see what's the shortest number of pages.

01:27.810 --> 01:31.320
And that's that tells us 176 is the shortest.

01:31.740 --> 01:35.190
So of course maximum works the same way.

01:35.460 --> 01:40.200
So instead of men we just type Max and my X and does the same thing.

01:40.200 --> 01:44.700
So here we're finding that while it doesn't do the same thing it works in the same way but it does the

01:44.700 --> 01:46.000
exact opposite.

01:46.380 --> 01:52.120
It's going to tell us or return the longest or the highest number of pages.

01:52.140 --> 01:58.230
So if we do that I'll just recall that last line and just change it to be Max

02:00.750 --> 02:02.510
634.

02:02.880 --> 02:08.700
That is our longest book and we can do the same thing with year if we wanted to

02:12.810 --> 02:16.210
2017 is our most recent years the highest number year.

02:16.500 --> 02:20.930
So that's the very basics of maximun minute Max have you on say it.

02:21.090 --> 02:25.350
I do want to call your attention to something sort of weird.

02:25.350 --> 02:31.680
What if I wanted to get the title of the longest book not just the number of pages like we have here.

02:32.010 --> 02:36.140
Just finding out that 634 is a longest.

02:36.330 --> 02:37.790
Isn't that useful.

02:37.800 --> 02:40.440
What if I wanted to know what is the book What's the title.

02:40.440 --> 02:42.020
Who wrote it.

02:42.090 --> 02:43.020
The year is released.

02:43.020 --> 02:44.530
Any other information.

02:44.970 --> 02:48.630
Well you might think you could do this.

02:48.630 --> 03:00.220
Select max page is common title from books and if we try it out select max pages common title from books

03:01.810 --> 03:08.020
it says that the namesake is our longest book and it has 634 pages.

03:08.320 --> 03:17.180
And while yes 634 is the maximum pages in our entire database The Namesake is not 634 pages.

03:17.350 --> 03:27.010
And in fact if we just do a select and let's just do title comic pages from books if we find the namesake

03:27.130 --> 03:33.770
you'll see that it's 291 pages and the one that is 634 is the Amazing Adventures of Kavalier and Clay.

03:34.330 --> 03:35.450
So that's a problem.

03:35.710 --> 03:37.600
Here's a nice slow graphic.

03:38.470 --> 03:42.260
It's the largest emoji that I can make and these slides for some reason.

03:42.520 --> 03:45.590
So I'm just going to go ahead and insert a much larger one now.

03:46.060 --> 03:48.760
Postproduction very fancy.

03:48.760 --> 03:51.140
So how how do we get around this.

03:51.190 --> 03:52.320
There has to be a way.

03:52.350 --> 03:54.770
In fact there's multiple ways in the next video.

03:54.820 --> 04:00.130
It's a bit of a cliffhanger here and the next video we're going to see a couple options including a

04:00.130 --> 04:06.130
preview of a more advanced method something that we haven't seen just yet but there is a way to do it

04:06.130 --> 04:07.740
using what we already know.

04:08.140 --> 04:10.370
Something we learned a couple of videos ago.

04:10.390 --> 04:11.230
All right.

04:11.500 --> 04:11.950
Next video.
