Usually MAX() or the like is a good way to ensure there is only one row out, but rownum=1 might be cheaper and OK if there is only one value. On one hand, MAX() folds all the rows together inside the engine, but rownum=1 allows a cursor to be created and filled, then discards each following row one by one at the presentation side. There are sample functions cheaper than max(), which evaluates every row, like FIRST_VALUE(), but it might insist on a sort:
FIRST_VALUE but doc says OVER() can be empty:
SQL Functions
or FIRST (also needs a sort):
FIRST
Hint for first rows 1 helps:
Comments
On a no-problem day, the sqlplus options pile is a fine way to return just the value, but on those other days, often including day 1 as you debug, for errors it is a bit of a train wreck. The sed and dAtA...eNdAtA approach works portably on all SQL tools, and saves the informative stuff to a log file for production support and debug.