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 )
--6.- PROVEEDORES 7.- CLIENTES
SELECT CASE WHEN LENGTH(RUC_PROV) = 11 AND RUC_PROV LIKE '10%' THEN SUBSTRING(RUC_PROV, 3, 8)
ELSE RUC_PROV END NUMDOC
,CASE WHEN LENGTH(RUC_PROV) = 11 AND RUC_PROV LIKE '10%' then '1'
WHEN LENGTH(RUC_PROV) = 11 AND RUC_PROV LIKE '20%' then '2'
WHEN LENGTH(RUC_PROV) = 8 then '1'
ELSE '3' end Cod_Tipo_Documento
,MAX(cast(case WHEN LOWER(RELACION_DSC) LIKE '%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_NUEVO_MERCADO_BPE
, 0 FLG_RESCATE_BPE
, 0 FLG_RESCATE_MICRO
, 0 FLG_PJ
, 0 FLG_CTA_NEG
, MAX(case when LOWER(RELACION_DSC) LIKE '%proveedor%' then 1 else 0 end) FLG_PROVEEDORES
, MAX(case when LOWER(RELACION_DSC) LIKE '%cliente%' then 1 else 0 end) FLG_CLIENTES
, 0 FLG_RESCATE_BE
, 0 FLG_BARRIDO_TLV_BPE
, 0 FLG_PNCN
, 0 FLG_RETAIL
, 0 FLG_ADQUISION_RIESGOS
, 0 FLG_RRLL_BPE_PJ
, 0 FLG_RRLL_DNI_CARNETEXT
FROM E_DW_VIEWS.V_MST_VPC_BASES_ECOSIS_BC
WHERE CAST(TO_CHAR(FECHA_BASE_DT, 'YYYYMM') AS INT) <= 202406 --- este se reemplaza por el parametro del SP
GROUP BY CASE WHEN LENGTH(RUC_PROV) = 11 AND RUC_PROV LIKE '10%' THEN SUBSTRING(RUC_PROV, 3, 8)
ELSE RUC_PROV END
,CASE WHEN LENGTH(RUC_PROV) = 11 AND RUC_PROV LIKE '10%' then '1'
WHEN LENGTH(RUC_PROV) = 11 AND RUC_PROV LIKE '20%' then '2'
WHEN LENGTH(RUC_PROV) = 8 then '1'
ELSE '3' END
Revise this Paste