SAP NetWeaver AS ABAP Release 752, ©Copyright 2017 SAP AG. All rights reserved.
ABAP - Keyword Documentation → ABAP - Reference → Processing External Data → ABAP Database Accesses → Open SQL → Open SQL - Operands and Expressions → Open SQL - Conditions sql_cond → sql_cond - rel_exp for Statements →sql_cond - subquery_clauses
Syntax
... { FROM source
FIELDS select_clause }
| { select_clause
FROM source }
[WHERE sql_cond]
[
GROUP BY group] [HAVING group_cond]
[
ORDER BY [UP TO n ROWS [OFFSET o]]]
[db_hints] ...
Effect
Possible clauses and additions of a subquery in a condition sql_cond in Open SQL.
The addition USING CLIENT must not be specified n the FROM clause. The automatic client handling of the subquery is performed in accordance with the client handling of the outer statement. If specified, an addition USING CLIENT of the outer statement also applies to the subquery.
A subquery can be used within the following relational expressions sql_cond for a subquery:
Conditions of a subquery can themselves contain subqueries. In nested subqueries, the columns specified in the SQL conditions are searched inside out and the columns of inner subqueries obscure columns with the same name in outer subqueries.
Only a limited number of SELECT statements can be used as subqueries in an Open SQL statement. The maximum number is defined so that the Open SQL statement can be executed on all supported database systems. If statically identifiable, more than 50 SELECT statements produce a syntax error or a runtime error. This restriction is independent of whether the subqueries are nested or occur in different relational expressions of the SQL condition.
The addition UP TO n ROWS can only be used after ORDER BY and the addition OFFSET can only be used after UP TO n ROWS. An ORDER BY clause in a subquery is not supported by all databases. This means a syntax check warning can occur that can be hidden using the pragma ##db_feature_mode[limit_in_subselect_or_cte]. If this is detected at runtime on a database that does not support the pragma, a handleable exception of the class CX_SY_SQL_UNSUPPORTED_FEATURE is raised.
Notes
Executable Example