ALL

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Tests whether a comparison between an expression and every row of a subquery is true. Returns a boolean result.

Syntax 

1<expression> <operator> ALL ( <subquery> )

Arguments 

Required 

  • <expression>: The left-hand value to evaluate and compare against each row of the subquery result.
  • <operator>: A comparison operator that returns a boolean result that’s applied between the left-hand expression and each subquery row.
  • <subquery>: A parenthesized subquery that returns exactly one column.

Returns 

Returns true if every subquery row yields true, including when the subquery returns no rows. Returns false if any comparison yields false.

Returns NULL if no comparison with a subquery row returns false and at least one comparison returns NULL.

Considerations 

  • The subquery must return exactly one column.
  • NOT IN is equivalent to <> ALL.
  • Tip: To avoid unexpected results, filter out NULL values in your subquery (for example, WHERE column IS NOT NULL) when using ALL or NOT IN. A single NULL can cause the entire expression to return NULL instead of TRUE.

Examples 

Compare Against Every Subquery Row 

Return rows whose value is greater than every value in the subquery result.

1SELECT col1
2FROM tab1
3WHERE col1 > ALL (SELECT col2 FROM tab2 WHERE col2 IS NOT NULL);

Empty Subquery Result 

When the subquery returns no rows, ALL returns true because every row (of which there are none) trivially satisfies the comparison.

1SELECT 1 = ALL (SELECT col2 FROM tab2 WHERE 1 = 0) AS result;

Returns true.

Related Documentation