1 00:00:00,210 --> 00:00:00,630 Okay. 2 00:00:00,630 --> 00:00:05,250 So next up, we're going to continue on with two new functions. 3 00:00:05,250 --> 00:00:06,570 And they go together. 4 00:00:06,570 --> 00:00:10,050 They fit well there, min and max, minimum and maximum. 5 00:00:10,050 --> 00:00:12,720 And they do what they sound like, what their name says. 6 00:00:12,720 --> 00:00:19,110 They help you find and identify minimum values in a table or maximum values in a table, and we can 7 00:00:19,110 --> 00:00:25,470 use them on their own and we can also combine them with group by to get further insights. 8 00:00:25,470 --> 00:00:27,180 So we're going to see how to do both. 9 00:00:27,480 --> 00:00:31,260 We're going to start off by using Min and Max without group by. 10 00:00:31,960 --> 00:00:36,420 So we can do things like find the minimum release here in our entire table. 11 00:00:36,430 --> 00:00:39,910 So what was the first year any book was released? 12 00:00:40,270 --> 00:00:48,760 And to do that just looks like this select min release here in parentheses from books. 13 00:00:49,150 --> 00:00:54,130 So just like we did with Count, where you could just count all the books if you wanted to, you can 14 00:00:54,130 --> 00:00:55,930 just use Min on its own. 15 00:00:56,020 --> 00:00:57,280 So let me show you how to do that. 16 00:00:57,280 --> 00:01:06,790 Now, go over to cloud nine and we can just do a select min released here from. 17 00:01:08,050 --> 00:01:08,770 Books. 18 00:01:10,260 --> 00:01:14,220 And 1945 is the earliest book that we have released. 19 00:01:14,340 --> 00:01:21,830 The earliest years that a book was released, we could also do something like select min pages if we 20 00:01:21,840 --> 00:01:24,510 want to see what's the shortest number of pages. 21 00:01:27,710 --> 00:01:31,040 And that's that tells us 176 is the shortest. 22 00:01:31,670 --> 00:01:35,150 So of course, maximum works the same way. 23 00:01:35,240 --> 00:01:40,190 So instead of min, we just type Max, Max and it does the same thing. 24 00:01:40,190 --> 00:01:42,410 So here we're finding, well, it doesn't do the same thing. 25 00:01:42,410 --> 00:01:45,860 It works in the same way, but it does the exact opposite. 26 00:01:46,460 --> 00:01:51,940 It's going to tell us or return the longest or the highest number of pages. 27 00:01:51,950 --> 00:01:53,390 So if we do that. 28 00:01:55,310 --> 00:01:58,490 Just recall that last line and just change it to be Max. 29 00:02:00,740 --> 00:02:02,240 634. 30 00:02:02,720 --> 00:02:08,930 That is our longest book and we can do the same thing with yea if we wanted to. 31 00:02:12,780 --> 00:02:14,820 2017 is our most recent year. 32 00:02:14,820 --> 00:02:16,110 It's the highest number of year. 33 00:02:16,380 --> 00:02:19,530 So that's the very basics of maximum in or minute max. 34 00:02:19,560 --> 00:02:20,490 However you want to say it. 35 00:02:21,000 --> 00:02:24,720 I do want to call your attention to something sort of weird. 36 00:02:25,200 --> 00:02:27,690 What if I wanted to get the title of the longest book? 37 00:02:27,690 --> 00:02:31,350 Not just the number of pages like we have here. 38 00:02:31,890 --> 00:02:36,120 Just finding out that 634 is the longest. 39 00:02:36,360 --> 00:02:37,690 Isn't that useful? 40 00:02:37,710 --> 00:02:38,910 What if I wanted to know? 41 00:02:38,910 --> 00:02:39,810 What is the book? 42 00:02:39,810 --> 00:02:40,440 What's the title? 43 00:02:40,470 --> 00:02:41,250 Who wrote it? 44 00:02:42,090 --> 00:02:43,050 The year is released. 45 00:02:43,050 --> 00:02:44,310 Any other information? 46 00:02:44,790 --> 00:02:47,970 Well, you might think you could do this. 47 00:02:48,480 --> 00:02:52,380 Select max pages, comma title from books. 48 00:02:53,010 --> 00:02:57,960 And if we try it out, select max pages. 49 00:02:57,960 --> 00:03:00,480 Comma title from books. 50 00:03:01,810 --> 00:03:08,080 It says that The Namesake is our longest book and it has 634 pages. 51 00:03:08,080 --> 00:03:17,130 And while, yes, 634 is the maximum pages in our entire database, the namesake is not 634 pages. 52 00:03:17,140 --> 00:03:24,310 And in fact, if we just do a select and let's just do title pages from books. 53 00:03:25,870 --> 00:03:29,290 If we find the namesake, you'll see that it's 291 pages. 54 00:03:29,290 --> 00:03:33,490 And the one that has 634 is The Amazing Adventures of Kavalier and Clay. 55 00:03:34,300 --> 00:03:35,440 So that's a problem. 56 00:03:35,590 --> 00:03:37,390 Here's a nice little graphic I made. 57 00:03:38,470 --> 00:03:42,130 It's the largest emoji that I could make on these slides for some reason. 58 00:03:42,490 --> 00:03:44,980 So I'm just going to go ahead and insert a much larger one now. 59 00:03:45,910 --> 00:03:46,970 Post production. 60 00:03:47,080 --> 00:03:47,950 Very fancy. 61 00:03:48,670 --> 00:03:50,470 So how how do we get around this? 62 00:03:51,070 --> 00:03:52,210 There has to be a way. 63 00:03:52,210 --> 00:03:53,750 And in fact, there's multiple ways. 64 00:03:53,770 --> 00:03:58,140 In the next video, it's a bit of a cliffhanger here, but the next video, we're going to see a couple 65 00:03:58,140 --> 00:04:04,420 of options, including a preview of a more advanced method, something that we haven't seen just yet. 66 00:04:04,780 --> 00:04:07,750 But there is a way to do it using what we already know. 67 00:04:08,050 --> 00:04:10,060 Something we learned a couple of videos ago. 68 00:04:10,300 --> 00:04:10,960 All right. 69 00:04:11,410 --> 00:04:12,190 Next video.