1 00:00:00,090 --> 00:00:07,440 The next operator will look at is greater than we can use, greater than to filter or to select, let's 2 00:00:07,440 --> 00:00:13,820 say, books released after the year 2000 where release here is greater than 2000. 3 00:00:13,830 --> 00:00:20,220 So instead of doing a strict equal to 2000, we can now get every book released after 2000. 4 00:00:20,310 --> 00:00:21,900 It's relatively straightforward. 5 00:00:22,110 --> 00:00:31,200 I won't spend too much time on this, but let's do select Star from books where released year is greater 6 00:00:31,200 --> 00:00:33,750 than I don't know how about 2005? 7 00:00:35,170 --> 00:00:37,480 And of course, it's zoomed in too much. 8 00:00:37,510 --> 00:00:43,630 It's hard for me to see the whole table printed out like this, but we can see we've got 20, 16, 12, 9 00:00:43,630 --> 00:00:50,920 13, ten, 14 and 17, only six rows compared to, I think 19 that are in the table otherwise. 10 00:00:51,940 --> 00:00:56,350 So we could use it to do a different sort of comparison of the different column. 11 00:00:56,350 --> 00:00:58,600 How about select the star from books? 12 00:00:58,600 --> 00:01:02,470 We want the really long books where pages is greater than 500. 13 00:01:03,400 --> 00:01:10,650 And we get these for my life in Words, which is made up 634 Amazing Adventures. 14 00:01:10,660 --> 00:01:13,300 Kavalier and Clay 634 where I'm calling from. 15 00:01:13,300 --> 00:01:14,500 It's 526. 16 00:01:14,500 --> 00:01:16,310 The Circle is 504. 17 00:01:16,330 --> 00:01:17,590 So that works great. 18 00:01:17,950 --> 00:01:21,730 That's kind of the quick and easy part about using greater than. 19 00:01:21,730 --> 00:01:27,700 And one side note I want to talk about is what do you think this evaluates to if you have any programming 20 00:01:27,700 --> 00:01:34,130 experience in another language, JavaScript, Python, something like that, you might have an inkling. 21 00:01:34,150 --> 00:01:36,040 If you don't, then don't worry about it. 22 00:01:36,040 --> 00:01:38,410 But think about what this might evaluate to. 23 00:01:38,770 --> 00:01:41,920 The answer is it evaluates to a number. 24 00:01:41,950 --> 00:01:48,070 If I do select about 80 greater than 40, well, we know that that's true. 25 00:01:48,100 --> 00:01:52,700 And if you have programming experience, you might expect it to return a Boolean value. 26 00:01:52,720 --> 00:01:54,050 True or false? 27 00:01:54,070 --> 00:01:57,730 Now, if you've never heard the term boolean, don't worry, it does not matter. 28 00:01:57,910 --> 00:02:00,940 But in fact what it returns is the number one. 29 00:02:00,940 --> 00:02:04,390 So if something evaluates to true, this would be true. 30 00:02:04,390 --> 00:02:06,190 80 is indeed greater than 40. 31 00:02:06,190 --> 00:02:07,210 We get one. 32 00:02:07,330 --> 00:02:09,690 But what if I said is 80 greater than 100? 33 00:02:09,699 --> 00:02:11,080 That is not true. 34 00:02:11,110 --> 00:02:12,280 A.K.A false. 35 00:02:12,280 --> 00:02:14,080 So we get zero. 36 00:02:14,770 --> 00:02:23,890 So when we do something like select, let's not do star, let's do title and pages and released year 37 00:02:23,890 --> 00:02:25,030 from books. 38 00:02:25,770 --> 00:02:33,780 When I do this and I try and filter where pages is greater than 500, let's just do that again. 39 00:02:33,780 --> 00:02:41,250 Where pages is greater than 500, my SQL is going to go through each one of these and it's going to 40 00:02:41,250 --> 00:02:42,230 check pages. 41 00:02:42,240 --> 00:02:46,860 What's the result of running 367 greater than 500? 42 00:02:46,860 --> 00:02:50,610 And if it gets zero, it does not include that row. 43 00:02:50,640 --> 00:02:55,110 And if it gets one, which is true, then it will include that row. 44 00:02:55,260 --> 00:02:57,450 And that's how we end up with these rows. 45 00:02:57,450 --> 00:03:00,930 504634526634. 46 00:03:01,080 --> 00:03:05,280 Now we're going to talk a little bit more about null values later in this section, but let's just see 47 00:03:05,280 --> 00:03:09,060 what happens when I do something like select 50. 48 00:03:09,060 --> 00:03:11,100 Or how about this is one greater than null? 49 00:03:12,180 --> 00:03:13,720 Oh, the answer is no. 50 00:03:13,740 --> 00:03:18,120 So when we try and do these operations with Noel, we get some really weird results. 51 00:03:18,120 --> 00:03:23,400 But it's actually it's not that weird because remember, Noel represents the lack of a value. 52 00:03:23,520 --> 00:03:27,540 So how can we compare a number like one to nothingness? 53 00:03:27,780 --> 00:03:34,440 So maybe I guess you could make the case that it should return false or zero, but it makes more sense, 54 00:03:34,440 --> 00:03:36,540 in my opinion, that we just get nothing back. 55 00:03:36,570 --> 00:03:37,860 You try and compare something to nothing. 56 00:03:38,010 --> 00:03:39,450 We can't do anything about it. 57 00:03:39,450 --> 00:03:45,030 So just know that you'll always get Noel when we try and make these comparisons with NULL and some other 58 00:03:45,030 --> 00:03:45,750 value. 59 00:03:46,140 --> 00:03:50,910 So that's why those pages, those books are not included that have null as their pages. 60 00:03:50,910 --> 00:03:52,340 And that's it for this video. 61 00:03:52,350 --> 00:03:56,520 We've got a bit more to cover with greater than less than greater than or equal to in the next.