Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as SQL by registered user vvillacorta ( 2 years ago )
SELECT A.*, M.KEY_VALUE NUM_DOCUMENTO_HASH, P.KEY_VALUE NUM_RUC_HASH
FROM(
SELECT NUM_DOCUMENTO,
CASE WHEN MAX(S.NUMRUC) IS NOT NULL THEN MAX(S.NUMRUC)
WHEN LENGTH(MAX(A.NUM_DOCUMENTO)) = 11 THEN MAX(A.NUM_DOCUMENTO)
ELSE NULL END NUM_RUC
FROM E_DW_VIEWS.V_FEEDBACK_TELEVENTAS A
LEFT JOIN E_DW_VIEWS.V_DATOS_PRINCIPALES_SUNAT S
ON (CASE WHEN SUBSTR(A.NUM_DOCUMENTO,1,2) = '10' AND LENGTH(A.NUM_DOCUMENTO) = 11 THEN SUBSTR(A.NUM_DOCUMENTO,3,8) ELSE A.NUM_DOCUMENTO END) =
(CASE WHEN SUBSTR(S.NUMRUC,1,2) = '10' AND LENGTH(S.NUMRUC) = 11 THEN SUBSTR(S.NUMRUC,3,8) ELSE S.NUMRUC END)
WHERE GESTION = '202304'
GROUP BY NUM_DOCUMENTO
) A
LEFT JOIN E_DW_VIEWS.V_MST_ENCRIP_NRO_DOC_MDL_HISTDIA M
ON A.NUM_DOCUMENTO = M.NRO_DOC
LEFT JOIN E_DW_VIEWS.V_MST_ENCRIP_NRO_DOC_MDL_HISTDIA P
ON A.NUM_RUC = P.NRO_DOC
WHERE A.NUM_RUC IS NOT NULL
AND A.NUM_RUC NOT LIKE ''
AND A.NUM_RUC <> '.'
Revise this Paste