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 ( 3 years ago )
CREATE MULTISET TABLE ..........................................HM_CIMA_RCC_CLASS_PREVIA AS (
    SELECT PERIODO, RUC,
	COUNT(CASE WHEN DIF=2 OR DIF IS NULL THEN CTDENTIDADREPORTANTE ELSE 0 END) AS CTDENTDEUDORAS,
	MAX(CASE WHEN DIF=2 OR DIF IS NULL THEN PCTNORMAL ELSE 0 END) AS PCTNORMAL,
	MAX(CASE WHEN DIF=2 OR DIF IS NULL THEN PCTCPP ELSE 0 END) AS PCTCPP,
	MAX(CASE WHEN DIF=2 OR DIF IS NULL THEN PCTDEFICIENTE ELSE 0 END) AS PCTDEFICIENTE,
	MAX(CASE WHEN DIF=2 OR DIF IS NULL THEN PCTDUDOSO ELSE 0 END) AS PCTDUDOSO,
	MAX(CASE WHEN DIF=2 OR DIF IS NULL THEN PCTPERDIDA ELSE 0 END) AS PCTPERDIDA,

	MAX(CASE WHEN DIF<=4 OR DIF IS NULL THEN PCTNORMAL ELSE 0 END) AS PCTNORMAL_3M,
	MAX(CASE WHEN DIF<=4 OR DIF IS NULL THEN PCTCPP ELSE 0 END) AS PCTCPP_3M,
	MAX(CASE WHEN DIF<=4 OR DIF IS NULL THEN PCTDEFICIENTE ELSE 0 END) AS PCTDEFICIENTE_3M,
	MAX(CASE WHEN DIF<=4 OR DIF IS NULL THEN PCTDUDOSO ELSE 0 END) AS PCTDUDOSO_3M,
	MAX(CASE WHEN DIF<=4 OR DIF IS NULL THEN PCTPERDIDA ELSE 0 END) AS PCTPERDIDA_3M,

	MAX(CASE WHEN DIF<=7 OR DIF IS NULL THEN PCTNORMAL ELSE 0 END) AS PCTNORMAL_6M,
	MAX(CASE WHEN DIF<=7 OR DIF IS NULL THEN PCTCPP ELSE 0 END) AS PCTCPP_6M,
	MAX(CASE WHEN DIF<=7 OR DIF IS NULL THEN PCTDEFICIENTE ELSE 0 END) AS PCTDEFICIENTE_6M,
	MAX(CASE WHEN DIF<=7 OR DIF IS NULL THEN PCTDUDOSO ELSE 0 END) AS PCTDUDOSO_6M,
	MAX(CASE WHEN DIF<=7 OR DIF IS NULL THEN PCTPERDIDA ELSE 0 END) AS PCTPERDIDA_6M,

	MAX(PCTNORMAL) AS PCTNORMAL_12M,
	MAX(PCTCPP) AS PCTCPP_12M,
	MAX(PCTDEFICIENTE) AS PCTDEFICIENTE_12M,
	MAX(PCTDUDOSO) AS PCTDUDOSO_12M,
	MAX(PCTPERDIDA) AS PCTPERDIDA_12M
	
	FROM .................................................HM_CIMA_RCC_CLASS
	GROUP BY PERIODO, RUC
)
WITH DATA PRIMARY INDEX (PERIODO, RUC);

 

Revise this Paste

Your Name: Code Language: