Welcome, guest! Login / Register - Why register?
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 )
FROM (
     SELECT COALESCE(AA.NUM_DOCUMENTO, T.NUM_DOCUMENTO) NUM_DOCUMENTO_COMPLETO, AA.*
	 FROM E_DW_VIEWS.V_FEEDBACK_TELEVENTAS AA
	 LEFT JOIN (
		SELECT NUM_DOCUMENTO, NUM_TELEFONO
		FROM E_DW_VIEWS.V_FEEDBACK_TELEVENTAS 
		WHERE GESTION = '202210' 
		AND NUM_DOCUMENTO IS NOT NULL AND NUM_TELEFONO IS NOT NULL
		QUALIFY ROW_NUMBER() OVER(PARTITION BY NUM_TELEFONO ORDER BY (
		    CASE WHEN LENGTH(NUM_DOCUMENTO) = 11 AND  (CATEGORIA = 'CE' OR RESULTADO_LLAMADA LIKE '(CE)') THEN 1
			     WHEN LENGTH(NUM_DOCUMENTO) = 11 AND  (CATEGORIA = 'CNE' OR RESULTADO_LLAMADA LIKE '(CNE)') THEN 2
				 WHEN LENGTH(NUM_DOCUMENTO) = 11 AND  (CATEGORIA = 'ET' OR RESULTADO_LLAMADA LIKE '(ET)') THEN 3
				 WHEN LENGTH(NUM_DOCUMENTO) = 11 AND  (CATEGORIA = 'NC' OR RESULTADO_LLAMADA LIKE '(NC)') THEN 4
		         WHEN CATEGORIA = 'CE' OR RESULTADO_LLAMADA LIKE '(CE)' THEN 5
			     WHEN CATEGORIA = 'CNE' OR RESULTADO_LLAMADA LIKE '(CNE)' THEN 6
				 WHEN CATEGORIA = 'ET' OR RESULTADO_LLAMADA LIKE '(ET)' THEN 7
				 WHEN CATEGORIA = 'NC' OR RESULTADO_LLAMADA LIKE '(NC)' THEN 8
				 ELSE 9 END
		) ASC ) = 1
	) T
	ON AA.NUM_TELEFONO = T.NUM_TELEFONO AND AA.NUM_DOCUMENTO IS NULL
	WHERE 1 = 1
	AND AA.GESTION = '202210'
	AND AA.RESULTADO_LLAMADA NOT IN (
	  'ININ-OUTBOUND-CONTACT-ATTEMPT-LIMIT-SKIPPED',
	  'ININ-OUTBOUND-EXTERNALLY-THROTTLED',
	  'ININ-OUTBOUND-LIVE-VOICE','ININ-OUTBOUND-PREVIEW-SKIPPED',
	  'SIP: [486]', 'SIP: [500]', 'SIP: [503]',
	  'ININ-OUTBOUND-NUMBER_COULD_NOT_BE_DIALED',
	  'ININ-OUTBOUND-NUMBERS-INVALID',
	  'ININ-OUTBOUND-RULE-ERROR-SKIPPED',
	  'ININ-OUTBOUND-RULE-SKIPPED')
	 
 ) A

 

Revise this Paste

Your Name: Code Language: