Lesson 5: Filtering results using the WHERE Clause and GREATER THAN.

By Alan Hylands — 1 minute read

SQL WHERE Clause Comparison Operators.

The WHERE clause also lets us use a range of other comparison operators.

We'll look at a list of the different comparison operators we can use and see an example of the Greater Than operator action. You should familiar with most of these from school maths class but it never hurts to have a refresher.

Most common comparison operators.

OperatorDescription
=Equal to
!=NOT Equal to
<>NOT Equal to
<Less than
<=Less than OR Equal to
>Greater than
>=Greater than OR Equal to

An example with GREATER THAN.

The GREATER THAN operator lets us filter our data table on numerical fields where the value is greater than the value we specify. For example, to get all products that cost more than $10 our query would be:

SELECT * 
FROM Products
WHERE price > 10;

Quiz Time.

The Question.

This mission is going to require a little lifting of things off the top shelf. That means we need characters with a little height to help us out (sorry Spidey).

Write a SQL query that gets us all characters with height greater than 180cm.

The Data.

The Editor.


Run SQL


Show Answer

The Answer.

Correct SQL:

                    SELECT * FROM characters WHERE height > 180;
                    

Correct Output:

Try the next lesson