Skip to Content
avatar image
Former Member

sap hana top 1 in subquery

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" =

Add comment
10|10000 characters needed 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.


  • Get RSS Feed

0 Answers