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 ( 5 months ago )
--DROP TABLE IF EXISTS tmp_modelos_despliegue_fin_ventas_202407
SELECT CODMES, NUM_RUC, MIN(PRODUCTO) PRODUCTO_1, MAX(PRODUCTO) PRODUCTO_2
INTO tmp_modelos_despliegue_fin_ventas_202407
FROM ODS.HM_GESCOM_TLV_DESPLIEGUE_CAMPAÑAS
WHERE 1 = 1
AND CODMES in ('202407')
AND PRODUCTO in('Descuento Electrónico','Factura Negociable')
GROUP BY CODMES, NUM_RUC
--DROP TABLE IF EXISTS tmp_modelos_fin_ventas_segmento_ruc
SELECT AA.CODMES, AA.NUM_RUC,
CASE WHEN BB.segmento_contacto IS NULL THEN '3.Medio'
ELSE BB.segmento_contacto END priorizacion
INTO tmp_modelos_fin_ventas_segmento_ruc
FROM tmp_modelos_despliegue_fin_ventas_202407 AA
LEFT JOIN (
SELECT codmes_campana, num_ruc, prioridad_contacto, segmento_contacto
FROM MM_UNIVERSO_TEL
WHERE prioridad_contacto = 1
) BB
ON AA.CODMES = BB.codmes_campana
AND AA.NUM_RUC = BB.num_ruc
SELECT CODMES, priorizacion, count(1), count(distinct(NUM_RUC))
FROM tmp_modelos_fin_ventas_segmento_ruc
GROUP BY CODMES, priorizacion
ORDER BY CODMES, priorizacion
Revise this Paste