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 Plain Text by registered user vvillacorta ( 3 years ago )
DROP TABLE IF EXISTS ..............HM_SOW_BPE
CREATE TABLE ..............HM_SOW_BPE
WITH ( format = 'Parquet',
parquet_compression = 'SNAPPY',
partitioned_by = ARRAY['PERIODO'],
external_location= 's3://................................................................/HM_SOW_BPE/'
)
AS (
SELECT CODSBS,
SUM(coalesce(MTOSALDO_REAJUSTADO, 0)) SALDO_COL_VIG,
SUM(CASE WHEN BANCO = 'IBK' THEN coalesce(MTOSALDO_REAJUSTADO, 0) ELSE 0 END) SALDO_COL_VIG_IBK,
SUM(CASE WHEN BANCO in ('BBVA', 'BCP', 'BIF', 'SCOTIA', 'MBCO') THEN coalesce(MTOSALDO_REAJUSTADO, 0) ELSE 0 END) SALDO_COL_VIG_OTROS_BANCOS,
SUM(CASE WHEN BANCO = 'CAJAS & FINANC.' THEN coalesce(MTOSALDO_REAJUSTADO, 0) ELSE 0 END) SALDO_COL_VIG_CAJAS,
CASE WHEN SUM(coalesce(MTOSALDO_REAJUSTADO, 0)) <= 0 THEN 0 ELSE SUM(CASE WHEN BANCO = 'IBK' THEN coalesce(MTOSALDO_REAJUSTADO, 0) ELSE 0 END) / SUM(coalesce(MTOSALDO_REAJUSTADO, 0)) END SOW_IBK,
CASE WHEN SUM(coalesce(MTOSALDO_REAJUSTADO, 0)) <= 0 THEN 0 ELSE SUM(CASE WHEN BANCO in ('BBVA', 'BCP', 'BIF', 'SCOTIA', 'MBCO') THEN coalesce(MTOSALDO_REAJUSTADO, 0) ELSE 0 END) / SUM(coalesce(MTOSALDO_REAJUSTADO, 0)) END SOW_OTROS_BANCOS,
CASE WHEN SUM(coalesce(MTOSALDO_REAJUSTADO, 0)) <= 0 THEN 0 ELSE SUM(CASE WHEN BANCO = 'CAJAS & FINANC.' THEN coalesce(MTOSALDO_REAJUSTADO, 0) ELSE 0 END) / SUM(coalesce(MTOSALDO_REAJUSTADO, 0)) END SOW_CAJAS,
CAST(PERIODO as VARCHAR) PERIODO
FROM ..............T2_SALDO_MERCADO_SF_REAJUSTADO
WHERE 1 = 1
AND FLG_BPE_TIMELINE = 1
AND CAST(PERIODO as VARCHAR) >= '202008'
AND TIPO_PRODUCTO IN ('COL. DIRECTAS', 'COL. INDIRECTAS')
AND SITUACION = 'VIGENTE'
AND FLG_LIN_MERCADO = 'S'
AND (
PRODUCTO NOT IN ('OTROS')
--OR
--(
-- PRODUCTO ='OTROS' AND
-- DETALLE IN ('FINANCIACION DE PROYECTOS')
--)
)
GROUP BY CODSBS, PERIODO
)
Revise this Paste