SQL
Subquery Comparisons: `ALL`, `ANY` and `SOME`
In the section on [scalar subqueries](#::scalar-subquery), a scalar expression was compared directly to a subquery using the equality [comparison operator](#docs:sql:expressions:comparison_operators::comparison-operators) (` =`).
Such direct comparisons only make sense with scalar subqueries.  
Scalar expressions can still be compared to single-column subqueries returning multiple rows by specifying a quantifier. Available quantifiers are `ALL`, `ANY` and `SOME`. The quantifiers `ANY` and `SOME` are equivalent.  
#### `ALL` {#docs:sql:expressions:subqueries::all}  
The `ALL` quantifier specifies that the comparison as a whole evaluates to `true` when the individual comparison results of _the expression at the left hand side of the comparison operator_ with each of the values from _the subquery at the right hand side of the comparison operator_ **all** evaluate to `true`:  
```sql
SELECT 6 <= ALL (SELECT grade FROM grades) AS adequate;
```  
returns:  
| adequate |
|----------|
| true     |  
because 6 is less than or equal to each of the subquery results 7, 8 and 9.  
However, the following query  
```sql
SELECT 8 >= ALL (SELECT grade FROM grades) AS excellent;
```  
returns  
| excellent |
|-----------|
| false     |  
because 8 is not greater than or equal to the subquery result 7. And thus, because not all comparisons evaluate `true`, `>= ALL` as a whole evaluates to `false`.  
#### `ANY` {#docs:sql:expressions:subqueries::any}  
The `ANY` quantifier specifies that the comparison as a whole evaluates to `true` when at least one of the individual comparison results evaluates to `true`.
For example:  
```sql
SELECT 5 >= ANY (SELECT grade FROM grades) AS fail;
```  
returns  
| fail  |
|-------|
| false |  
because no result of the subquery is less than or equal to 5.  
The quantifier `SOME` maybe used instead of `ANY`: `ANY` and `SOME` are interchangeable.