SAP WHERE LOGEXP ALL ANY SOME



Get Example source ABAP code based on a different SAP table
  


Short Reference
• ALL ( SELECT ... ) ABAP_OSQL_COND
• ANY ( SELECT ... ) ABAP_OSQL_COND
• SOME ( SELECT ... ) ABAP_OSQL_COND

ABAP_SQLCOND - ALL, ANY, SOME

ABAP_SYNTAX
... operand operator $[ALL$|ANY$|SOME$] ( SELECT subquery_clauses $[UNION$|INTERSECT$|EXCEPT ...$] ) ...

What does it do?
Comparison of an operand operand with the result set of a subquery. The clauses in the subquery subquery_clauses must represent a scalar subquery. The set operators UNION, INTERSECT, and EXCEPT can be used to combine the result sets of multiple subqueries. In this case, special rules query_clauses apply to specifying clauses.
Any SQL expressions except aggregate expressions and window expressions can be specified for operand. In a HAVING clause, aggregate expressions can also be used.
operator stands for a comparison operator. Result sets can be single row or multirow.



Latest notes:

NON_V5_HINTS
When an SQL expression occurs on the left side, the syntax check is performed in a ABAP_STRICT_760 strict mode / , which handles the statement more strictly than the regular syntax check.
ABAP_HINT_END

Single Row Result Set
If the result set of the subquery defined by the clause subquery_clauses contains only one row, the comparison can be performed without specifying ALL, ANY, or SOME. The expression is true if the corresponding comparison of the value of the operand operand with the result of the scalar subquery subquery returns true. If the result set for the subquery contains multiple rows, an uncatchable exception is raised when the statement is executed.

ABAP_EXAMPLE_VX5
Reads the flights with the most passengers.
ABEXA 01391
ABAP_EXAMPLE_END

Multirow Result Set
If the result set of the subquery defined by the clause subquery_clauses contains more than one row, ALL, ANY, or SOME must be specified.
If using ALL, the expression is true if the comparison is true for all rows in the result set of the scalar subquery subquery.
If the addition ANY or SOME is used, the expression is true if the comparison is true for at least one of the rows in the result set of the subquery.



Latest notes:

The equality operator (= or EQ) in conjunction with ANY or SOME acts like IN subquery.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Reads the customer numbers of the customers who made the most bookings.
ABEXA 01392
ABAP_EXAMPLE_END