Código SQL:
Ver original
SELECT "msisdn", "status", "optin_date", "optout_date", (trunc("optout_date")-trunc("optin_date")) AS "life" FROM "subscriber" WHERE "status" = 0 UNION ALL SELECT "msisdn", "status", "optin_date", "optout_date", (trunc(sysdate)-trunc("optin_date")) AS "life" FROM "subscriber" WHERE "status" = 1;
Código SQL:
Ver original
SELECT "msisdn", "status", "optin_date", "optout_date", CASE "status" WHEN 0 THEN (trunc("optout_date")-trunc("optin_date")) WHEN 1 THEN (trunc(sysdate)-trunc("optin_date")) END AS "life" FROM "subscriber";
Código SQL:
Ver original
SELECT "msisdn", "status", "optin_date", "optout_date", decode ("status", 0 , (trunc("optout_date")-trunc("optin_date")) , 1 , (trunc(sysdate)-trunc("optin_date")) ) AS "life" FROM "subscriber";
esta es la tabla (subscriber):
Código SQL:
Ver original
Name NULL? TYPE ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- id NOT NULL NUMBER(11) id_user NOT NULL NUMBER(11) id_service NOT NULL NUMBER(11) msisdn NOT NULL NUMBER(20) nextbill NOT NULL DATE credits NOT NULL NUMBER(11) failed_trys NOT NULL NUMBER(11) last_attempt DATE STATUS NOT NULL NUMBER(4) optin_date NOT NULL DATE optout_date DATE id_source NOT NULL NUMBER(11) id_campaign NOT NULL NUMBER(20) id_campaign_detail_promo_sms NOT NULL NUMBER(20)
alguien que pueda dar algún consejo de optimizacion ??
gracias!!