Skip to Content

sap hana top 1 in subquery

Nov 23, 2017 at 08:35 AM


avatar image

I'm trying to do a subquery with TOP1 which isn't supported so I was reading that LIMIT 1 should work I'm still getting similar error single-row query returns more than one row


SELECT (SELECT Top 1 ("BatchNum") FROM IBT1 WHERE "BaseEntry" = t1."DocEntry" AND "BaseNum" = t0."DocNum" AND "ItemCode" = t1."ItemCode" AND "BaseLinNum" = t1."LineNum" ) AS "Batch"

FROM OPDN t0 LEFT JOIN PDN1 t1 ON t0."DocEntry" = t1."DocEntry"

LEFT JOIN INV1 t2 ON t2."BaseEntry" = t1."DocEntry"

AND t2."BaseLine" = t1."LineNum"

LEFT JOIN OINV t3 ON t3."DocEntry" = t2."DocEntry"

WHERE t0."DocEntry" =

10 |10000 characters needed characters left characters exceeded

Can you provide more details on your question, e.g. the complete statement instead of a "cut off statement" and that one with the correct LIMIT syntax?

And what is the data below your query? You are doing a join on different tables which can result in several lines. The Limit on the sub-query has not limiting effect on the outer query.


* Please Login or Register to Answer, Follow or Comment.

0 Answers