select A16.*
,CASE WHEN ( A16.AUTORIZA IS NULL
AND ( SELECT COUNT(*)
FROM OWNER.TABELA
WHERE CAMPO1 = 1
AND CAMPO2 = '2171200006643'
AND NUM_RIESGO = 470 ) <> ( SELECT COUNT(*)
FROM OWNER.TABELA
WHERE CAMPO1 = 1
AND CAMPO2 = '2171200006643'
AND RISCO = 470
AND AUTORIZA = 'S' )
) THEN 'FALHA NA APROVAÇÃO'
ELSE 'APROVADO'
END ANALISE
from OWNER.TABELA A16
where A16.CAMPO1 = 1
and A16.CAMPO2 = '2171200006643'
AND A16.RISCO = 470
Well, maybe someone asks: but why do not you just bring the fields filled then?
Why do I need to know the fields that have not been filled as well because an error code is generated. I'm just trying to make it easier since we have to analyze a sequence of several tables and some specific flags.
I do not know if it was clear, could you understand? Will the cube or the rollup help in this case?
If someone has any suggestions, I'm waiting.
Thanks.
Att.,