What is the difference between SELECT SINGLE and SELECT ... UP TO 1 ROWS, and when do you read with a full key?
Say your answer out loud first.
Practise another way
SELECT SINGLE is meant for reading one row by its complete primary key, so the result is unique and can use the table buffer. UP TO 1 ROWS takes the first row of a possibly larger result, so with several matches I must add ORDER BY to make it deterministic.
If the WHERE does not cover the full key, SELECT SINGLE hides non-uniqueness, and ATC will flag it. I use SINGLE only with a full key.
Both read at most one row. They differ in intent and in what you can rely on.
SELECT SINGLE
- Reads one row into a structure. The intent is a unique row, so the
WHEREshould cover the complete primary key with=conditions. - If several rows match, the database returns one of them. Nothing says which. That is a silent bug if the key was incomplete.
- With a full key on a buffered table, the single-record buffer can serve it.
ORDER BYis not allowed withSINGLE.
UP TO n ROWS
- Reads the first n rows of a result set. With
UP TO 1 ROWSand anORDER BY, you get the smallest or latest row, for example the most recent document for a customer. - Without
ORDER BYthe first row is arbitrary, likeSINGLE. - The result goes to a structure or an internal table, and
UP TOfollows theINTOclause in the modern syntax.
" unique row by full key
SELECT SINGLE FROM scarr
FIELDS carrname
WHERE carrid = @carrid
INTO @DATA(name).
" latest flight date of a carrier: not a key lookup, so order it
SELECT FROM sflight
FIELDS fldate
WHERE carrid = @carrid
ORDER BY fldate DESCENDING
INTO TABLE @DATA(latest)
UP TO 1 ROWS.
Existence checks: if I only need to know whether a row exists, I select one cheap column (or use an EXISTS subquery in the WHERE), not the whole row.
Why full key matters on HANA: a full key hits the primary-key lookup directly. A partial key becomes a scan or index search, and SINGLE stops it at the first hit, which can look fast in test and be unpredictable in production.
I also say: the SELECT SINGLE vs UP TO 1 ROWS question has older folklore about performance. On a modern system the real difference is determinism and buffering, not speed.
Ties SINGLE to a full key and uniqueness, uses ORDER BY with UP TO 1 ROWS, and mentions the silent arbitrary-row risk.
Repeats 'SINGLE is faster' or 'UP TO 1 ROWS reads all rows first' without a reason, and never mentions the full key.
Using SELECT SINGLE with a partial key and trusting the row that comes back. It looks like a lookup but returns an arbitrary match.
- Can you use ORDER BY with SELECT SINGLE?
- What does sy-subrc tell you after SELECT SINGLE?
- How do you check existence without reading a row?
- Which one can use the table buffer?
1 official page and 4 prep guides. Confidence: high. Checked 21 Nov 2026.
- Official page Backs the answer.
- Prep guide Gives the question.
- Prep guide Gives the question.
- Prep guide Gives the question.
- Prep guide Gives the question.