Welcome to the group for Brazil users. .All discussions will be in Portuguese.
1) Crie um mapa
Mapping_ocorren:
mapping LOAD
NOTA_FISCAL,
CONCAT(DISTINCT OCORREN,',') AS OCORRENCIAS_PEDIDO
FROM seuqvd(qvd)
GROUP BY NOTA_FISCAL ;
2) Use esse mapa para calcular seu campo
IF(Index(ApplyMap('Mapping_ocorren',NOTA_FISCAL,''),'2021')>0,'S-Atendido',
IF(Index(ApplyMap('Mapping_ocorren',NOTA_FISCAL,''),'2001')>0,'D-Devolução',
IF(Index(ApplyMap('Mapping_ocorren',NOTA_FISCAL,''),'2003')>0,'P-Parcial','A-Aberto'))) AS PEDIDO_ATENDIDO,