이렇게 수정해 보셔요~
SELECT HQ_CODE,
DECODE(A,1,
(SELECT MAX(b.BASIC_SEQ) FROM EGRPTEQSS b
WHERE b.ANSWER_GRADE = 'Y' AND b.HQ_CODE = a.HQ_CODE),
(SELECT MAX(b.BASIC_SEQ) FROM EGRPTEQSS b
WHERE b.ANSWER_GRADE = 'N' AND b.HQ_CODE = a.HQ_CODE))
BASIC_SEQ
FROM (
SELECT HQ_CODE,
SIGN(SUM(DECODE(ANSWER_GRADE,'Y',1,0))) A
FROM EGRPTEQSS
WHERE ANSWER_GRADE IS NOT NULL
GROUP BY HQ_CODE
) A