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 )
CREATE TABLE DLAB_PROGRAMADATOSVPC.HM_UNIVERSO_4_BPE as(
		   --5.- CTA NEG
		SELECT CASE WHEN d.Tipo_Identificacion_Host='2' AND Numero_Identificacion LIKE '10%' THEN SUBSTRING(Numero_Identificacion, 3, 8) ELSE Numero_Identificacion END NUMDOC
			, cast('5.- CTA NEG' AS varchar(50)) CATEGORIA
			, 0 FLG_ADI
			, '.' logica_banca_mes_val, '.'  logica_banca_fin_val, '.'  Banca_Mes_Val, '.'  Banca_Fin_Val, '.'  LOGICA
			, 0 FLG_MERCADO_BPE
			, 0 FLG_RESCATE_BPE
			, 0 FLG_RESCATE_MICRO
			, 0 FLG_PJ
		    , 1 FLG_CTA_NEG
		    , 0 FLG_PROVEEDORES
		    , 0 FLG_CLIENTES
			, 0 FLG_RESCATE_BE
		    , 0 FLG_BARRIDO_TLV_BPE
			, 0 FLG_PNCN
			, 0 FLG_RETAIL
			--select count(1)	
			from E_DW_VIEWS.V_AGG_VPC_SALDOS_DIARIOS b 
			inner  join E_DW_VIEWS.V_DIM_CLIENTE d
			on d.Cliente_Id = b.Cliente_Id
			where 1=1
			--and b.Saldo_Promedio_Sol_Mto>0
			and b.Categoria_Prod_VPC_Dsc like '%NEGOCIO%'
			and b.Fecha_Saldo_Dt = ADD_MONTHS(CAST('202210'||'01' AS DATE FORMAT 'YYYYMMDD'),1)-1
		UNION ALL
		--6.- PROVEEDORES 7.- CLIENTES
		SELECT CASE WHEN LENGTH(Ruc_Beneficiario) = 11 AND Ruc_Beneficiario LIKE '10%' THEN SUBSTRING(Ruc_Beneficiario, 3, 8) ELSE Ruc_Beneficiario END NUMDOC
				--numero_ruc NUM_RUC,
		   , cast(case when Tipo ='CLIENTE' then '7.- CLIENTES' else '6.- PROVEEDORES' end AS varchar(50)) CATEGORIA
		   , 0 FLG_ADI
		   , '.'  logica_banca_mes_val, '.'  logica_banca_fin_val, '.'  Banca_Mes_Val, '.'  Banca_Fin_Val, '.'  LOGICA
			, 0 FLG_MERCADO_BPE
			, 0 FLG_RESCATE_BPE
			, 0 FLG_RESCATE_MICRO
			, 0 FLG_PJ
		    , 0 FLG_CTA_NEG
		    , (case when Tipo <> 'CLIENTE' then 1 else 0 end) FLG_PROVEEDORES
			, (case when Tipo = 'CLIENTE' then 1 else 0 end) FLG_CLIENTES
			, 0 FLG_RESCATE_BE
		    , 0 FLG_BARRIDO_TLV_BPE
			, 0 FLG_PNCN
			, 0 FLG_RETAIL
			--select count(1)
			--select max(Periodo_Val)
			FROM  E_DW_VIEWS.V_FACT_VPC_CORPORATIVO
			where Periodo_Val = '202210'
			) WITH DATA
			PRIMARY INDEX (NUMDOC);			
			
			
	
CREATE TABLE DLAB_PROGRAMADATOSVPC.HM_UNIVERSO_4_BPE as(	
	SELECT ZZ.CODDOC NUMDOC
		, cast('12.- RRLL POTENCIAL BPE' AS varchar(50)) CATEGORIA
		, 0 FLG_ADI
		, '.' logica_banca_mes_val, '.'  logica_banca_fin_val, '.'  Banca_Mes_Val, '.'  Banca_Fin_Val, '.'  LOGICA
		, 0 FLG_MERCADO_BPE
		, 0 FLG_RESCATE_BPE
		, 0 FLG_RESCATE_MICRO
		, 0 FLG_PJ
	    , 0 FLG_CTA_NEG
	    , 0 FLG_PROVEEDORES
	    , 0 FLG_CLIENTES
		, 0 FLG_RESCATE_BE
	    , 0 FLG_BARRIDO_TLV_BPE
		, 0 FLG_PNCN
		, 0 FLG_RETAIL
		, 1 FLG_RRLL_BPE_PJ
		, ZZ.FLG_RRLL_DNI_CARNETEXT
	FROM (
		SELECT S.CODDOC,
		       S.TIPDOC,
		       MAX(CASE WHEN TIPDOC IN ('1','3') THEN 1 ELSE 0 END) FLG_RRLL_DNI_CARNETEXT
		FROM E_DW_VIEWS.V_REP_LEGALES_SUNAT_HIST S
		INNER JOIN DLAB_PROGRAMADATOSVPC.HM_UNIVERSO_1_BPE U
		ON S.NUMRUC = U.NUMDOC
		LEFT JOIN E_DW_VIEWS.V_DATOS_PRINCIPALES_SUNAT_HIST P
		ON S.NUMRUC = P.NUMRUC
		WHERE 1 = 1
		AND S.ESTADO = 0
		AND S.FECPROCESO = '05/11/2022'
		AND P.FECPROCESO = '05/11/2022'
		AND P.NUMRUC LIKE '20%'
		GROUP BY S.CODDOC, S.TIPDOC		
	) ZZ
) WITH DATA
PRIMARY INDEX (NUMDOC);

 

Revise this Paste

Your Name: Code Language: