Comparing Values

Learn how to compare a column with a range of values.

The ALL(), SOME(), and ANY() clauses are often used along with subqueries in a WHERE statement. They are used to compare a single value with a range of values. Here’s the basic syntax:

SELECT * FROM TableSchema.TableName
WHERE SomeColumn > ANY([SELECT subquery that returns a range of values]);

Here, SomeColumn is compared with the values returned by the SELECT subquery. The exact behavior of the comparison is determined by our choice of ALL(), SOME(), or ANY(). Let’s consider the following tables and data in the Tournament database.

Get hands-on with 1200+ tech skills courses.