I've already posted this question to which I got an answer from Henka,
but it doesn't work, perhaps because I have oversimplified the problem.
This is the formulation of the function which more closely resembles the
actual problem for which "GROUP BY" doesn't cut it because with it I get
another error - ora-00979: not a GROUP BY expression:
(iA_ID IN INTEGER)
RETURN VARCHAR2 IS
BEGIN sAName := null;
SELECT decode(count(*),0,NULL, decode(ptest,0,NULL,'P') || '-' ||
WHERE A_ID = iA_ID
GROUP BY ptest;
The actual query contains two dozens concatenated DECODEs.
Placing any one of them in the GROUP BY clause causes the said
error ora-00979. Placing all of them in that clause would be ludicrous.
And besides, I fear the GROUP BY clause would cause the same error
even in the simple context I posted first.
Have you tested your suggestion, Henka, or was it a general hint?