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 ( 8 months ago )
SELECT GESTION, COUNT(1) CONTEO_GENERAL, COUNT(distinct(NUM_DOCUMENTO)) conteo_distinto_doc,
COUNT(distinct(NUMRUC)) conteo_distinto_sunat, COUNT(distinct(NUM_RUC)) conteo_distinto_rescate,
COUNT(distinct(NUM_DOCUMENTO_HASH)) conteo_distinto_doc_hash, COUNT(distinct(NUM_RUC_HASH)) conteo_distinto_ruc_hash,
COUNT(distinct(CASE WHEN NUM_RUC_HASH IS NULL THEN NUM_DOCUMENTO_HASH ELSE NUM_RUC_HASH END)) conteo_distinto_doc_ruc_hash,
COUNT(distinct(KEY_EXTRA)) conteo_distinto_extra_hash,
SUM(FLG_RUC_NULO)
FROM(
SELECT CASE WHEN A.NUM_RUC IS NULL OR A.NUM_RUC LIKE '' OR A.NUM_RUC = '.' THEN 1 ELSE 0 END FLG_RUC_NULO,
A.NUM_DOCUMENTO, A.NUMRUC, A.NUM_RUC, A.GESTION,
M.KEY_VALUE NUM_DOCUMENTO_HASH, P.KEY_VALUE NUM_RUC_HASH,
K.KEY_VALUE KEY_EXTRA
FROM(
SELECT CASE WHEN S.NUMRUC IS NOT NULL THEN S.NUMRUC
WHEN LENGTH(A.NUM_DOCUMENTO) = 11 THEN A.NUM_DOCUMENTO
ELSE NULL END NUM_RUC,
A.NUM_DOCUMENTO, S.NUMRUC, A.GESTION
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 >= '202301'
) 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
LEFT JOIN E_DW_VIEWS.V_MST_ENCRIP_NRO_DOC_MDL_HISTDIA K
ON A.NUM_DOCUMENTO = SUBSTRING(K.KEY_VALUE, 1, 60)
) X
GROUP BY GESTION
SELECT CASE WHEN A.NUM_RUC IS NULL OR A.NUM_RUC LIKE '' OR A.NUM_RUC = '.' THEN 1 ELSE 0 END FLG_RUC_NULO,
CASE WHEN LENGTH(A.NUM_DOCUMENTO) = 11 AND A.NUM_DOCUMENTO LIKE '20%' THEN 1
WHEN K.KEY_VALUE is not null and LENGTH(K.NRO_DOC) = 11 AND K.NRO_DOC LIKE '20%' THEN 1
ELSE 0 END flg_ruc_20,
A.NUM_DOCUMENTO, LENGTH(A.NUM_DOCUMENTO) LEN_DOCUMENTO, A.NUM_TELEFONO, LENGTH(A.NUM_TELEFONO) LEN_NUM_TELEFONO,
A.NUMRUC, A.NUM_RUC, A.GESTION,
M.KEY_VALUE NUM_DOCUMENTO_HASH, M.NRO_DOC,
P.KEY_VALUE NUM_RUC_HASH, P.NRO_DOC,
K.KEY_VALUE KEY_EXTRA, K.NRO_DOC
FROM(
SELECT CASE WHEN S.NUMRUC IS NOT NULL THEN S.NUMRUC
WHEN LENGTH(A.NUM_DOCUMENTO) = 11 THEN A.NUM_DOCUMENTO
ELSE NULL END NUM_RUC,
A.NUM_DOCUMENTO, S.NUMRUC, A.GESTION, A.NUM_TELEFONO
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'
) 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
LEFT JOIN E_DW_VIEWS.V_MST_ENCRIP_NRO_DOC_MDL_HISTDIA K
ON A.NUM_DOCUMENTO = SUBSTRING(K.KEY_VALUE, 1, 60)
WHERE M.KEY_VALUE IS NULL
SELECT * FROM E_DW_VIEWS.V_MST_ENCRIP_NRO_DOC_MDL_HISTDIA WHERE NRO_DOC= '10701728721'
SELECT * FROM E_DW_VIEWS.V_MST_ENCRIP_NRO_DOC_MDL_HISTDIA WHERE KEY_VALUE LIKE '%4CA83FC1CC562CFC5503189E1781816253BCBC9193EA4DFD4E9A2DB3F363%'
SELECT * FROM E_DW_VIEWS.V_MST_ENCRIP_NRO_DOC_MDL_HISTDIA WHERE NRO_DOC= '10701728721'
E_DW_VIEWS.V_FEEDBACK_TELEVENTAS
SELECT COUNT(1), COUNT(DISTINCT(NRO_TELEF))
FROM E_DW_VIEWS.V_MST_ENCRIP_NROTELEF_MDL_HIST
SELECT TOP 100 NRO_TELEF, TELEF_VALUE, length(TELEF_VALUE) FROM E_DW_VIEWS.V_MST_ENCRIP_NROTELEF_MDL_HIST
SELECT CODMES, COUNT(1)
FROM E_DW_VIEWS.V_MST_ENCRIP_NRO_DOC_MDL_HISTDIA
GROUP BY CODMES
ORDER BY CODMES DESC
SELECT TOP 2000 * FROM E_DW_VIEWS.V_MST_ENCRIP_NRO_DOC_MDL_HISTDIA
SELECT M.key_value numdoc_val, P.key_value numruc_val,
A.id_conversacion, A.codigo_unico, A.tipo_documento, A.num_telefono,
A.tip_cliente, A.gestion, A.fec_llamada,
A.duracion_llamada, A.hor_inicio_llamada, A.hor_fin_llamada, A.telefono_contacto, A.resultado_llamada,
A.agente, A.nombre_agente, A.flag_reagendamiento, A.fecha_reagendamiento, A.hora_reagendamiento, A.contact_list, A.nom_lista, A.tipo_lista,
A.id_grabacion_audio, A.id_campania, A.id_tratamiento, A.id_oferta, A.cod_campania, A.cod_tratamiento, A.cod_oferta, A.prefijo_campana,
A.fecinformacion, A.categoria, A.peso_llamada, A.gestion p_gestion
FROM(
SELECT A.GESTION,
CASE
WHEN K.KEY_VALUE IS NULL THEN A.NUM_DOCUMENTO
ELSE K.NRO_DOC
END NUM_DOCUMENTO,
CASE WHEN S.NUMRUC IS NOT NULL THEN S.NUMRUC
WHEN LENGTH(A.NUM_DOCUMENTO) = 11 THEN A.NUM_DOCUMENTO
WHEN K.KEY_VALUE IS NOT NULL AND LENGTH(K.NRO_DOC) = 11 THEN K.NRO_DOC
ELSE NULL END NUM_RUC,
CASE WHEN T.TELEF_VALUE IS NULL THEN A.NUM_TELEFONO
ELSE T.NRO_TELEF
END NUM_TELEFONO,
A.ID_CONVERSACION, A.CODIGO_UNICO, A.TIPO_DOCUMENTO, A.TIP_CLIENTE, A.FEC_LLAMADA, A.DURACION_LLAMADA,
A.HOR_INICIO_LLAMADA, A.HOR_FIN_LLAMADA, A.TELEFONO_CONTACTO, A.RESULTADO_LLAMADA, A.AGENTE, A.NOMBRE_AGENTE,
A.FLAG_REAGENDAMIENTO, A.FECHA_REAGENDAMIENTO, A.HORA_REAGENDAMIENTO, A.CONTACT_LIST, A.NOM_LISTA,
A.TIPO_LISTA, A.ID_GRABACION_AUDIO, A.ID_CAMPANIA, A.ID_TRATAMIENTO, A.ID_OFERTA, A.COD_CAMPANIA,
A.COD_TRATAMIENTO, A.COD_OFERTA, A.PREFIJO_CAMPANA, A.FECINFORMACION, A.CATEGORIA, A.PESO_LLAMADA
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)
LEFT JOIN E_DW_VIEWS.V_MST_ENCRIP_NRO_DOC_MDL_HISTDIA K
ON A.NUM_DOCUMENTO = SUBSTRING(K.KEY_VALUE, 1, 60)
LEFT JOIN E_DW_VIEWS.V_MST_ENCRIP_NROTELEF_MDL_HIST T
ON A.NUM_TELEFONO = SUBSTRING(T.TELEF_VALUE, 1, 60)
WHERE GESTION = '202304' -------------- EL MES A PROCESAR
) 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
SELECT
A.GESTION,
A.NUM_DOCUMENTO AS validaDNI,
CASE
WHEN K.KEY_VALUE IS NULL THEN K1.KEY_VALUE
ELSE K.KEY_VALUE
END NUM_DOCUMENTO,
S.NUMRUC AS VALIDADRUC,
CASE
WHEN K2.KEY_VALUE IS NULL THEN
CASE WHEN Length(A.NUM_DOCUMENTO) = 11 THEN K1.KEY_VALUE
ELSE
CASE WHEN Length(K.NRO_DOC) = 11 THEN K.KEY_VALUE END
END
ELSE K2.KEY_VALUE
END NUMRUC_VAL,
CASE WHEN S.NUMRUC IS NOT NULL THEN S.NUMRUC
WHEN Length(A.NUM_DOCUMENTO) = 11 THEN A.NUM_DOCUMENTO
WHEN K.KEY_VALUE IS NOT NULL AND Length(K.NRO_DOC) = 11 THEN K.NRO_DOC
ELSE NULL END NUM_RUC,
CASE WHEN T.TELEF_VALUE IS NULL THEN A.NUM_TELEFONO
ELSE T.TELEF_VALUE
END NUM_TELEFONO,
A.ID_CONVERSACION, A.CODIGO_UNICO, A.TIPO_DOCUMENTO, A.TIP_CLIENTE, A.FEC_LLAMADA, A.DURACION_LLAMADA,
A.HOR_INICIO_LLAMADA, A.HOR_FIN_LLAMADA, A.TELEFONO_CONTACTO, A.RESULTADO_LLAMADA, A.AGENTE, A.NOMBRE_AGENTE,
A.FLAG_REAGENDAMIENTO, A.FECHA_REAGENDAMIENTO, A.HORA_REAGENDAMIENTO, A.CONTACT_LIST, A.NOM_LISTA,
A.TIPO_LISTA, A.ID_GRABACION_AUDIO, A.ID_CAMPANIA, A.ID_TRATAMIENTO, A.ID_OFERTA, A.COD_CAMPANIA,
A.COD_TRATAMIENTO, A.COD_OFERTA, A.PREFIJO_CAMPANA, A.FECINFORMACION, A.CATEGORIA, A.PESO_LLAMADA
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)
LEFT JOIN E_DW_VIEWS.V_MST_ENCRIP_NRO_DOC_MDL_HISTDIA K --CRUCE CON ENCRIPTADO
ON A.NUM_DOCUMENTO = Substring(K.KEY_VALUE, 1, 60)
LEFT JOIN E_DW_VIEWS.V_MST_ENCRIP_NROTELEF_MDL_HIST T
ON A.NUM_TELEFONO = Substring(T.TELEF_VALUE, 1, 60)
LEFT JOIN E_DW_VIEWS.V_MST_ENCRIP_NRO_DOC_MDL_HISTDIA K1 --CUCRE SIN ENCRIPTAR LA CLAVE ES EL CAMPO K1.NRO_DOC
ON A.NUM_DOCUMENTO = K1.NRO_DOC
LEFT JOIN E_DW_VIEWS.V_MST_ENCRIP_NRO_DOC_MDL_HISTDIA K2
ON S.NUMRUC = K2.NRO_DOC
--ON A.NUM_TELEFONO = Substring(T.KEY_VALUE, 1, 60)
WHERE A.GESTION = '202304' -------------- EL MES A PROCESAR
AND K.KEY_VALUE IS NOT NULL
SELECT TOP 100 *
FROM E_DW_VIEWS.V_DIM_VPC_CTA_CTBLE_RCC
WHERE PRODUCTO_RCC_DESC ='OTROS'
AND Cuenta_Ctble_RCD_Desc IN ('FINANCIACION DE PROYECTOS')
SELECT TOP 100 * FROM TMP_JTT_CODUNICOCLI
SELECT TOP 100 * FROM E_DW_VIEWS.V_DIM_VPC_CTA_CTBLE_RCC
Revise this Paste