Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so dont bother with any of their useless mail servers here and just use oauth login instead. Thank the nice Russians for causing that. :)

Paste

Pasted as SQL by registered user vvillacorta ( 2 years 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

Your Name: Code Language: