I want to check if two columns of two tables are indeed related. For which I am using a simple INTERSECT between two columns of different tables that I know are related. If a match in data is found, that would mean data from one table is present in the other.
select customid from sbook
INTERSECT
select id from scustom
However, this results in an error> Query Execution failed UP TO n ROWS currently cannot be used in INTERSECT
How to get this going?
ABAP open SQL statement UP TO n ROWS gets converted to LIMIT n in native SQL.
Please note that DDL SQL of CDS views has limitations and it doesnt support neither 'UP TO n ROWS' nor TOP/LIMIT statements.
Option 1: Is to implement CDS table function which uses HANA Native SQL and has support for TOP/LIMIT statements. Sample code is as below.
Option 2: If the CDS view is accessed from ABAP code, you can add UP TO n ROWS to the select statement in ABAP.