CREATE MULTISET TABLE .........................UNIVERSO_RCC_CIMA AS (
SELECT PERIODO, RUC,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudadirecta ELSE NULL END),0) AS mtodeudadirecta,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudaindirecta ELSE NULL END),0) AS mtodeudaindirecta,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudatotal ELSE NULL END),0) AS mtodeudatotal,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudaprodpersona ELSE NULL END),0) AS mtodeudaprodpersona,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudaprepersonal ELSE NULL END),0) AS mtodeudaprepersonal,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudatc ELSE NULL END),0) AS mtodeudatc,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudacredconvenio ELSE NULL END),0) AS mtodeudacredconvenio,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudacredhipotecario ELSE NULL END),0) AS mtodeudacredhipotecario,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudacredvehicular ELSE NULL END),0) AS mtodeudacredvehicular,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtofae ELSE NULL END),0) AS mtofae,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtogarantiafae ELSE NULL END),0) AS mtogarantiafae,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtogarantiareactiva ELSE NULL END),0) AS mtogarantiareactiva,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtogarantias ELSE NULL END),0) AS mtogarantias,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudainmobiliaria ELSE NULL END),0) AS mtodeudainmobiliaria,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtoreactiva ELSE NULL END),0) AS mtoreactiva,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudareprogramados ELSE NULL END),0) AS mtodeudareprogramados,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudacastigada ELSE NULL END),0) AS mtodeudacastigada,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudajudicial ELSE NULL END),0) AS mtodeudajudicial,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudareestructurado ELSE NULL END),0) AS mtodeudareestructurado,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudarefinanciado ELSE NULL END),0) AS mtodeudarefinanciado,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudavencido ELSE NULL END),0) AS mtodeudavencido,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudabcapersonavcd ELSE NULL END),0) AS mtodeudabcapersonavcd,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudabcapersonaref ELSE NULL END),0) AS mtodeudabcapersonaref,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudabcapersonajud ELSE NULL END),0) AS mtodeudabcapersonajud,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudainmobiliariavcd ELSE NULL END),0) AS mtodeudainmobiliariavcd,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudainmobiliariaref ELSE NULL END),0) AS mtodeudainmobiliariaref,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudainmobiliariajud ELSE NULL END),0) AS mtodeudainmobiliariajud,
COALESCE(AVG(CASE WHEN DIF2=2 THEN mtodeudainmobiliariarees ELSE NULL END),0) AS mtodeudainmobiliariarees,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudadirecta ELSE NULL END),0) AS mtodeudadirecta_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudaindirecta ELSE NULL END),0) AS mtodeudaindirecta_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudatotal ELSE NULL END),0) AS mtodeudatotal_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudaprodpersona ELSE NULL END),0) AS mtodeudaprodpersona_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudaprepersonal ELSE NULL END),0) AS mtodeudaprepersonal_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudatc ELSE NULL END),0) AS mtodeudatc_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudacredconvenio ELSE NULL END),0) AS mtodeudacredconvenio_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudacredhipotecario ELSE NULL END),0) AS mtodeudacredhipotecario_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudacredvehicular ELSE NULL END),0) AS mtodeudacredvehicular_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtofae ELSE NULL END),0) AS mtofae_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtogarantiafae ELSE NULL END),0) AS mtogarantiafae_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtogarantiareactiva ELSE NULL END),0) AS mtogarantiareactiva_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtogarantias ELSE NULL END),0) AS mtogarantias_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudainmobiliaria ELSE NULL END),0) AS mtodeudainmobiliaria_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtoreactiva ELSE NULL END),0) AS mtoreactiva_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudareprogramados ELSE NULL END),0) AS mtodeudareprogramados_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudacastigada ELSE NULL END),0) AS mtodeudacastigada_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudajudicial ELSE NULL END),0) AS mtodeudajudicial_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudareestructurado ELSE NULL END),0) AS mtodeudareestructurado_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudarefinanciado ELSE NULL END),0) AS mtodeudarefinanciado_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudavencido ELSE NULL END),0) AS mtodeudavencido_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudabcapersonavcd ELSE NULL END),0) AS mtodeudabcapersonavcd_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudabcapersonaref ELSE NULL END),0) AS mtodeudabcapersonaref_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudabcapersonajud ELSE NULL END),0) AS mtodeudabcapersonajud_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudainmobiliariavcd ELSE NULL END),0) AS mtodeudainmobiliariavcd_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudainmobiliariaref ELSE NULL END),0) AS mtodeudainmobiliariaref_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudainmobiliariajud ELSE NULL END),0) AS mtodeudainmobiliariajud_mean3,
COALESCE(AVG(CASE WHEN DIF2<=5 THEN mtodeudainmobiliariarees ELSE NULL END),0) AS mtodeudainmobiliariarees_mean3,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudadirecta ELSE NULL END),0) AS mtodeudadirecta_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudaindirecta ELSE NULL END),0) AS mtodeudaindirecta_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudatotal ELSE NULL END),0) AS mtodeudatotal_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudaprodpersona ELSE NULL END),0) AS mtodeudaprodpersona_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudaprepersonal ELSE NULL END),0) AS mtodeudaprepersonal_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudatc ELSE NULL END),0) AS mtodeudatc_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudacredconvenio ELSE NULL END),0) AS mtodeudacredconvenio_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudacredhipotecario ELSE NULL END),0) AS mtodeudacredhipotecario_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudacredvehicular ELSE NULL END),0) AS mtodeudacredvehicular_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtofae ELSE NULL END),0) AS mtofae_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtogarantiafae ELSE NULL END),0) AS mtogarantiafae_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtogarantiareactiva ELSE NULL END),0) AS mtogarantiareactiva_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtogarantias ELSE NULL END),0) AS mtogarantias_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudainmobiliaria ELSE NULL END),0) AS mtodeudainmobiliaria_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtoreactiva ELSE NULL END),0) AS mtoreactiva_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudareprogramados ELSE NULL END),0) AS mtodeudareprogramados_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudacastigada ELSE NULL END),0) AS mtodeudacastigada_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudajudicial ELSE NULL END),0) AS mtodeudajudicial_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudareestructurado ELSE NULL END),0) AS mtodeudareestructurado_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudarefinanciado ELSE NULL END),0) AS mtodeudarefinanciado_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudavencido ELSE NULL END),0) AS mtodeudavencido_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudabcapersonavcd ELSE NULL END),0) AS mtodeudabcapersonavcd_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudabcapersonaref ELSE NULL END),0) AS mtodeudabcapersonaref_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudabcapersonajud ELSE NULL END),0) AS mtodeudabcapersonajud_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudainmobiliariavcd ELSE NULL END),0) AS mtodeudainmobiliariavcd_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudainmobiliariaref ELSE NULL END),0) AS mtodeudainmobiliariaref_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudainmobiliariajud ELSE NULL END),0) AS mtodeudainmobiliariajud_mean6,
COALESCE(AVG(CASE WHEN DIF2<=8 THEN mtodeudainmobiliariarees ELSE NULL END),0) AS mtodeudainmobiliariarees_mean6,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudadirecta ELSE NULL END),0) AS mtodeudadirecta_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudaindirecta ELSE NULL END),0) AS mtodeudaindirecta_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudatotal ELSE NULL END),0) AS mtodeudatotal_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudaprodpersona ELSE NULL END),0) AS mtodeudaprodpersona_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudaprepersonal ELSE NULL END),0) AS mtodeudaprepersonal_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudatc ELSE NULL END),0) AS mtodeudatc_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudacredconvenio ELSE NULL END),0) AS mtodeudacredconvenio_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudacredhipotecario ELSE NULL END),0) AS mtodeudacredhipotecario_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudacredvehicular ELSE NULL END),0) AS mtodeudacredvehicular_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtofae ELSE NULL END),0) AS mtofae_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtogarantiafae ELSE NULL END),0) AS mtogarantiafae_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtogarantiareactiva ELSE NULL END),0) AS mtogarantiareactiva_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtogarantias ELSE NULL END),0) AS mtogarantias_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudainmobiliaria ELSE NULL END),0) AS mtodeudainmobiliaria_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtoreactiva ELSE NULL END),0) AS mtoreactiva_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudareprogramados ELSE NULL END),0) AS mtodeudareprogramados_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudacastigada ELSE NULL END),0) AS mtodeudacastigada_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudajudicial ELSE NULL END),0) AS mtodeudajudicial_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudareestructurado ELSE NULL END),0) AS mtodeudareestructurado_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudarefinanciado ELSE NULL END),0) AS mtodeudarefinanciado_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudavencido ELSE NULL END),0) AS mtodeudavencido_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudabcapersonavcd ELSE NULL END),0) AS mtodeudabcapersonavcd_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudabcapersonaref ELSE NULL END),0) AS mtodeudabcapersonaref_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudabcapersonajud ELSE NULL END),0) AS mtodeudabcapersonajud_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudainmobiliariavcd ELSE NULL END),0) AS mtodeudainmobiliariavcd_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudainmobiliariaref ELSE NULL END),0) AS mtodeudainmobiliariaref_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudainmobiliariajud ELSE NULL END),0) AS mtodeudainmobiliariajud_mean9,
COALESCE(AVG(CASE WHEN DIF2<=11 THEN mtodeudainmobiliariarees ELSE NULL END),0) AS mtodeudainmobiliariarees_mean9,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudadirecta ELSE NULL END),0) AS mtodeudadirecta_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudaindirecta ELSE NULL END),0) AS mtodeudaindirecta_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudatotal ELSE NULL END),0) AS mtodeudatotal_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudaprodpersona ELSE NULL END),0) AS mtodeudaprodpersona_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudaprepersonal ELSE NULL END),0) AS mtodeudaprepersonal_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudatc ELSE NULL END),0) AS mtodeudatc_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudacredconvenio ELSE NULL END),0) AS mtodeudacredconvenio_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudacredhipotecario ELSE NULL END),0) AS mtodeudacredhipotecario_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudacredvehicular ELSE NULL END),0) AS mtodeudacredvehicular_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtofae ELSE NULL END),0) AS mtofae_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtogarantiafae ELSE NULL END),0) AS mtogarantiafae_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtogarantiareactiva ELSE NULL END),0) AS mtogarantiareactiva_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtogarantias ELSE NULL END),0) AS mtogarantias_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudainmobiliaria ELSE NULL END),0) AS mtodeudainmobiliaria_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtoreactiva ELSE NULL END),0) AS mtoreactiva_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudareprogramados ELSE NULL END),0) AS mtodeudareprogramados_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudacastigada ELSE NULL END),0) AS mtodeudacastigada_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudajudicial ELSE NULL END),0) AS mtodeudajudicial_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudareestructurado ELSE NULL END),0) AS mtodeudareestructurado_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudarefinanciado ELSE NULL END),0) AS mtodeudarefinanciado_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudavencido ELSE NULL END),0) AS mtodeudavencido_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudabcapersonavcd ELSE NULL END),0) AS mtodeudabcapersonavcd_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudabcapersonaref ELSE NULL END),0) AS mtodeudabcapersonaref_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudabcapersonajud ELSE NULL END),0) AS mtodeudabcapersonajud_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudainmobiliariavcd ELSE NULL END),0) AS mtodeudainmobiliariavcd_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudainmobiliariaref ELSE NULL END),0) AS mtodeudainmobiliariaref_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudainmobiliariajud ELSE NULL END),0) AS mtodeudainmobiliariajud_mean12,
COALESCE(AVG(CASE WHEN DIF2<=14 THEN mtodeudainmobiliariarees ELSE NULL END),0) AS mtodeudainmobiliariarees_mean12,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudadirecta ELSE NULL END),0) AS mtodeudadirecta_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudaindirecta ELSE NULL END),0) AS mtodeudaindirecta_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudatotal ELSE NULL END),0) AS mtodeudatotal_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudaprodpersona ELSE NULL END),0) AS mtodeudaprodpersona_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudaprepersonal ELSE NULL END),0) AS mtodeudaprepersonal_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudatc ELSE NULL END),0) AS mtodeudatc_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudacredconvenio ELSE NULL END),0) AS mtodeudacredconvenio_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudacredhipotecario ELSE NULL END),0) AS mtodeudacredhipotecario_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudacredvehicular ELSE NULL END),0) AS mtodeudacredvehicular_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtofae ELSE NULL END),0) AS mtofae_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtogarantiafae ELSE NULL END),0) AS mtogarantiafae_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtogarantiareactiva ELSE NULL END),0) AS mtogarantiareactiva_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtogarantias ELSE NULL END),0) AS mtogarantias_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudainmobiliaria ELSE NULL END),0) AS mtodeudainmobiliaria_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtoreactiva ELSE NULL END),0) AS mtoreactiva_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudareprogramados ELSE NULL END),0) AS mtodeudareprogramados_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudacastigada ELSE NULL END),0) AS mtodeudacastigada_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudajudicial ELSE NULL END),0) AS mtodeudajudicial_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudareestructurado ELSE NULL END),0) AS mtodeudareestructurado_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudarefinanciado ELSE NULL END),0) AS mtodeudarefinanciado_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudavencido ELSE NULL END),0) AS mtodeudavencido_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudabcapersonavcd ELSE NULL END),0) AS mtodeudabcapersonavcd_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudabcapersonaref ELSE NULL END),0) AS mtodeudabcapersonaref_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudabcapersonajud ELSE NULL END),0) AS mtodeudabcapersonajud_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudainmobiliariavcd ELSE NULL END),0) AS mtodeudainmobiliariavcd_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudainmobiliariaref ELSE NULL END),0) AS mtodeudainmobiliariaref_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudainmobiliariajud ELSE NULL END),0) AS mtodeudainmobiliariajud_mean24,
COALESCE(AVG(CASE WHEN DIF2<=26 THEN mtodeudainmobiliariarees ELSE NULL END),0) AS mtodeudainmobiliariarees_mean24
FROM ......................HM_CIMA_RCC_2
GROUP BY PERIODO, RUC
)
WITH DATA PRIMARY INDEX (PERIODO, RUC);
Add a code snippet to your website: www.paste.org