The next operator will look at is greater than we can use, greater than to filter or to select, let's
say, books released after the year 2000 where release here is greater than 2000.
So instead of doing a strict equal to 2000, we can now get every book released after 2000.
It's relatively straightforward.
I won't spend too much time on this, but let's do select Star from books where released year is greater
than I don't know how about 2005?
And of course, it's zoomed in too much.
It's hard for me to see the whole table printed out like this, but we can see we've got 20, 16, 12,
13, ten, 14 and 17, only six rows compared to, I think 19 that are in the table otherwise.
So we could use it to do a different sort of comparison of the different column.
How about select the star from books?
We want the really long books where pages is greater than 500.
And we get these for my life in Words, which is made up 634 Amazing Adventures.
Kavalier and Clay 634 where I'm calling from.
It's 526.
The Circle is 504.
So that works great.
That's kind of the quick and easy part about using greater than.
And one side note I want to talk about is what do you think this evaluates to if you have any programming
experience in another language, JavaScript, Python, something like that, you might have an inkling.
If you don't, then don't worry about it.
But think about what this might evaluate to.
The answer is it evaluates to a number.
If I do select about 80 greater than 40, well, we know that that's true.
And if you have programming experience, you might expect it to return a Boolean value.
True or false?
Now, if you've never heard the term boolean, don't worry, it does not matter.
But in fact what it returns is the number one.
So if something evaluates to true, this would be true.
80 is indeed greater than 40.
We get one.
But what if I said is 80 greater than 100?
That is not true.
A.K.A false.
So we get zero.
So when we do something like select, let's not do star, let's do title and pages and released year
from books.
When I do this and I try and filter where pages is greater than 500, let's just do that again.
Where pages is greater than 500, my SQL is going to go through each one of these and it's going to
check pages.
What's the result of running 367 greater than 500?
And if it gets zero, it does not include that row.
And if it gets one, which is true, then it will include that row.
And that's how we end up with these rows.
504634526634.
Now we're going to talk a little bit more about null values later in this section, but let's just see
what happens when I do something like select 50.
Or how about this is one greater than null?
Oh, the answer is no.
So when we try and do these operations with Noel, we get some really weird results.
But it's actually it's not that weird because remember, Noel represents the lack of a value.
So how can we compare a number like one to nothingness?
So maybe I guess you could make the case that it should return false or zero, but it makes more sense,
in my opinion, that we just get nothing back.
You try and compare something to nothing.
We can't do anything about it.
So just know that you'll always get Noel when we try and make these comparisons with NULL and some other
value.
So that's why those pages, those books are not included that have null as their pages.
And that's it for this video.
We've got a bit more to cover with greater than less than greater than or equal to in the next.