Case statements with AND

Hi all.

I use a case statement to represent the values for different regions in a command prompt. I'm having some difficulties, with the values in the case statement. Here is an example of a simplified and shortened my code version.

CASE

WHEN 'Region '. "" Region name "="A"THEN"AMERICA ".

WHEN 'Region '. "" Region name "= 'B' THEN 'CHINA '.

WHEN 'Region '. "" Region name "= 'C' THEN 'EUROPE '.

WHEN 'Region '. "' Name of the region ' = 'A' AND 'B' AND 'C' THEN 'GLOBAL '.

END

My error when I use it in my statement. The formula is accepted, however, all the values are displayed in my guest except 'GLOBAL '.

How can I be able to assign a "GLOBAL"value in my guest? ".

Jagadekara I think that you do not get the point. Any given row retrieved from a data source cannot have all three at one point values!

AJ was trying to tell you, is that your CASE logic has no sense at all.

Tags: Business Intelligence

Similar Questions

  • Case statement with a select & date in

    Hello everyone,

    This is my first discussion, so please bare with me.

    I am trying to write a case statement with a select statement that compares the dates.

    When I write an instruction box with a select statement in it compares everything but dates it works fine.  Once the date is there, he collapses.

    Here is a super simple example of what I'm trying to do, "b.in_serv_dt" is a date

    Select unit_no,

    case when ((sélectionnez b.in_serv_dt de b unit_dept_comp_main où a.unit_id = b.unit_id et b.in_serv_dt) > = 1 January 2012 "") then "everybody wins."

    When ((sélectionnez b.in_serv_dt dans l'unit_dept_comp_main b où a.unit_id = b.unit_id et b.in_serv_dt) < = 1 January 2012 "") then "Nobody wins".

    end

    of ottawa_unitmain_v one

    Any help would be greatly appreciated

    Thank you very much

    Hello

    your statement of formatting:

    Select unit_no
    case when ((select b.in_serv_dt
    of unit_dept_comp_main b
    where a.unit_id = b.unit_id
    and b.in_serv_dt
    ") > = JANUARY 1, 2012"
    ) and then "everybody wins."
    When ((select b.in_serv_dt
    of unit_dept_comp_main b
    where a.unit_id = b.unit_id
    and b.in_serv_dt
    )<=>
    ) and then "no winner".
    end
    of ottawa_unitmain_v one

    I see "partial conditions": <... and="" b.in_serv_dt="">> that have no meaning.
    I guess it's a kind of "typo" and I ignore them.
    If the statement is:
    Select unit_no
    case when ((select b.in_serv_dt
    of unit_dept_comp_main b
    where a.unit_id = b.unit_id
    ") > = JANUARY 1, 2012"
    ) and then "everybody wins."
    When ((select b.in_serv_dt
    of unit_dept_comp_main b
    where a.unit_id = b.unit_id
    )<=>
    ) and then "no winner".
    end
    of ottawa_unitmain_v one

    I guess that the "b select" retrieve one line, through the design of database (forced...)

    As already written: be careful with data types: avoid "implicit conversions" (when you compare different data types, Oracle has convert the data type of the other side, a side example: "mystring = mynumber" is transformed into 'TO_NUMBER (mystring) = mynumber', or 'mydate = mystring' translates mydate = TO_DATE (mystring, ) ")
    Even better: use explicit conversions, use explicit formats when necessary.
    Best: use no conversion on columns from the constants, but use the correct data type for the constant.

    With this in mind:
    Select unit_no
    case when ((select b.in_serv_dt
    of unit_dept_comp_main b
    where a.unit_id = b.unit_id
    ) > DATE = ' 2012-01-01'
    ) and then "everybody wins."
    When ((select b.in_serv_dt
    of unit_dept_comp_main b
    where a.unit_id = b.unit_id
    )<= date="">
    ) and then "no winner".
    end
    of ottawa_unitmain_v one
    But note that b.in_serv_dt EQUAL to 1 January 2012 (at 00:00:00) is OK for both WHEN the conditions; then the a "win."

    Now: the subselect statement is identical in the 2 options of the case... You could work differently: (I add the "ELSE" in case one line as NULL in_serv_dt;) I guess that an INNER JOIN is OK, maybe you need a LEFT OUTER JOIN (if some lines of A have no corresponding row in B)

    SELECT a.unit_no
    , CASE WHEN b.in_serv_dt > = DATE '' 2012-01-01
    THEN "everyone wins"
    WHEN b.in_serv_dt< date="">
    While "Nobody wins".
    ELSE ' who knows... ". »
    END who_wins
    Of ottawa_unitmain_v one
    INNER JOIN unit_dept_comp_main b
    ON a.unit_id = b.unit_id
    ;

    Best regards

    Bruno Vroman

  • Help in the CASE statement with amount

    Hello Experts

    I amw Group on

    Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
    With partitioning, OLAP, Data Mining and Real Application Testing options

    I'm unable to solve this Case statement.

    My requirement is that if the value of the attribute is greater than 50, then add 1 to the sum for attribute 4 the sum should be 4


    WITH T AS
    (
    Select MATH_CONV_SCR 70, 68 MATH_PERC, writ_conv_scr 66, 67 writ_per Union double all the
    Select MATH_CONV_SCR 70, MATH_PERC 48, writ_conv_scr 66, 67 writ_per Union double all the
    Select MATH_CONV_SCR 70, 68 MATH_PERC, writ_conv_scr 66, 67 double writ_per
    )
    (
    Select)
    CASE
    WHEN MATH_CONV_SCR > 50 THEN 1
    WHEN MATH_PERC > 50 THEN 1
    WHEN WRIT_CONV_SCR > 50 THEN 1
    WHEN WRIT_PER > 50 THEN 1
    TOTAL END)
    T
    )


    The expected answer is
    4
    3
    4
    for the respective folders


    Please give me the solution

    Thank you

    RB

    Hello

    Rb2000rb65 wrote:
    Hello Experts

    I amw Group on

    Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production...

    Thanks for posting the version and sample data; It is very useful.

    ... Select)
    CASE
    WHEN MATH_CONV_SCR > 50 THEN 1
    WHEN MATH_PERC > 50 THEN 1
    WHEN WRIT_CONV_SCR > 50 THEN 1
    WHEN WRIT_PER > 50 THEN 1
    TOTAL END)
    T

    Don't forget that the WHEN of a CASE expression clauses are mutually exclusive. If none of them are evaluated to TRUE, then all of the following are not even tried.

    )

    The expected answer is
    4
    3
    4
    for the respective folders

    Please give me the solution

    Here's one way:

    SELECT  CASE WHEN math_conv_scr > 50 THEN 1 ELSE 0 END
          + CASE WHEN math_perc      > 50 THEN 1 ELSE 0 END
          +     CASE WHEN writ_conv_scr > 50 THEN 1 ELSE 0 END
          + CASE WHEN writ_per      > 50 THEN 1 ELSE 0 END     AS total
    FROM       t;
    
  • Case statement with building xml

    Select
    () XMLType.GetClobVal
    XMLElement ("variable"
    XMLAttributes (vcInternationalDate?" as "type")
    XMLAgg (XMLElement ("item",
    CASE WHEN THE TEMPO IS NOT NULL THEN
    , XMLElement ("utc", TO_CHAR (TIME,' dd/MM/YYYY HH24:MI:SS)) END))
    , XMLElement ("timezone_offSet", ZONE SCHEDULE)
    )
    )
    )
    )
    like 'CREATIONDATE '.
    of twgenericosdb. TEST
    WHERE ID = 1

    The query above without the case statement producing the result to follow:

    < type variable = "vcInternationalDate [:]" >
    < item >
    < utc > 2009-12-20 15:00 < / utc >
    < timezone_offSet > 3600000 < / timezone_offSet >
    < / point >
    < / variable >

    I'm looking for is a way in the case where the time utc is null statement do not tag the utc, utc is NULL the query returns the following result

    < type variable = "vcInternationalDate [:]" >
    < item >
    < utc > < / utc >
    < timezone_offSet > 3600000 < / timezone_offSet >
    < / point >
    < / variable >

    I'm trying to use the instruction box to return utc of the tag in the case of the UTC is NULL, but I get the error ORA-00917: Missing comma.

    Can someone help me?


    Thank you very much.

    Try

    SELECT XMLTYPE.GetClobVal
              (XMLELEMENT
                    ("variable",
                     XMLAttributes('vcInternationalDate[]' AS "type"),
                     XMLAGG(XMLELEMENT("item",
                                       CASE
                                          WHEN TEMPO IS NOT NULL
                                          THEN XMLELEMENT("utc", TO_CHAR(TIME, 'dd/MM/yyyy HH24:MI:SS'))
                                       END),
                            XMLELEMENT("timezone_offSet", TIMEZONE)))) AS "CREATIONDATE"
      FROM twgenericosdb.TEST
     WHERE ID = 1
    

    You can replace the CASE with NVL2

    SELECT XMLTYPE.GetClobVal
              (XMLELEMENT("variable",
                          XMLAttributes('vcInternationalDate[]' AS "type"),
                          XMLAGG(XMLELEMENT("item",
                                            NVL2(TEMPO,
                                                 XMLELEMENT("utc", TO_CHAR(TIME, 'dd/MM/yyyy HH24:MI:SS')),
                                                 NULL),
                                            XMLELEMENT("timezone_offSet", TIMEZONE))))) AS "CREATIONDATE"
      FROM twgenericosdb.TEST
     WHERE ID = 1
    

    URS

    Edited by: metzguar the 06.05.2010 15:04

  • Case statement with several ATHENS

    Try to see if the following is possible:

    -Case when regexp_like (code1, ' 123') or code1 = "456"

    then "Category1".

    Where regexp_like (code1, ' 123')

    then "Category2".

    Another null

    end category

    Then, of course, that no record being updated with the title of Category2 as criteria code1 already was met.

    I am trying to create 2 files for each instance of regexp_like (code1, ' 123').  One record with "Category1" and one with "Category2".

    Thank you

    I thought that too, but for this:

    I am trying to create 2 files for each instance of regexp_like (code1, ' 123')

    Looks like a job for the union of all the...

  • Case statement with endorsement instr

    Hi here is my code:
    Update table_1
    
    SET Financial_Review = ( case when instr(Judgement||Liquidation||under_admin,'Y') > 0 then  'Y' else 'N' end)
    This works perfectly. I now need to add another factor Debt_Review. The option is Debt_Review 0 or 1, where 1 means Y and 0 implies N.

    I essentially seeks to Debt_review in the update above statement. If the judgment or Liquidation or under_admin Y or Debt_Review is 1 then Financial_Review = O n else.

    Thanks in advance!

    Banner:
    Oracle Database 11 g Release 11.2.0.2.0 - 64 bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE 11.2.0.2.0 Production."
    AMT for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production

    Hello

    Use this...

    UPDATE table_1
       SET financial_review =
              (CASE
                  WHEN (   INSTR (judgement || liquidation || under_admin, 'Y') >
                                                                                 0
                        OR debt_review = 1
                       )
                     THEN 'Y'
                  ELSE 'N'
               END
              );
    

    I hope this helps...

    Thank you
    Prakash P

  • If statement with and / or

    I am trying to write an if statement which implies and or conditions.

    If (object1.rawValue! == null & & object2.presence == 'visible' | object3.rawVaule == 'Yes') {}

    Follow these steps...

    }

    The script above does not work. I want the script to fire if Object1 is not empty and either object2 is visible or object3 is equal to Yes (or both).

    If ((object1.rawValue! == null && object2.presence == "visible") |) (object1.rawValue! == null && object3.rawVaule == "Oui"))

    {
         Do the following...
    }
    

    This might help...

    Kind regards Mandy

  • Case statement with multiple queries to the THEN clause

    Y at - it a syntax something like:

    Case

    When A = 1
    Then B: = 2 and C: = 3

    When A = 2
    Then B: = 4 and C: = 5

    Else B: = 6 and C: = 7

    End case;

    where clause can then have multiple assignments?

    Also, how to mark entries as code on this forum?

    TIA,

    Extreme Farley

    You can simplify a bit:

    SQL> declare
      2     a number := 0;
      3     b number := 0;
      4     c number := 0;
      5  begin
      6
      7     Case A
      8          WHEN 1 Then
      9            B := 2;
     10            C := 3;
     11          WHEN 2 Then
     12            B := 4;
     13            C := 5;
     14          Else
     15            B := 6;
     16            C := 7;
     17     End Case;
     18     dbms_output.put_line('A=' || a);
     19     dbms_output.put_line('B=' || b);
     20     dbms_output.put_line('C=' || c);
     21  end;
     22  /
    A=0
    B=6
    C=7
    
    PL/SQL procedure successfully completed.
    
  • A CASE statement with additional where clause

    Hi all

    I need assistance in which this obligation clause

    Table:-balance_table

    Columns:-balance_type, balance_amount, balance_month, budget_name

    balance_type column had given 'Real' OR 'Budget '.

    Now I am trying to extract data such as: if: entered_month is Mar-2009 then before and including Mar-2009 will show real balance sheet Date and after Mar-2009 will show budget data.

    It works fine, I need to add a condition more restrict the budget name, there are several budget_name in the table for balance_type = 'Budget '.



    SELECT SUM (balance_amount), balance_type, balance_month
    OF balance_table
    WHERE balance_type =
    (CASE
    WHEN balance_month < =: entered_month
    THEN 'real '.
    ANOTHER 'Budget '.
    END
    )
    AND budget_name = 'BUDGET1.
    Balance_type GROUP, balance_month

    Stated above is erroneous because ' AND budget_name = ' BUDGET1 "clause restricts the set of data."

    Please help in contrcuting where clause 1) to sort the data according to Budget/actual and 2) for specific budgets, so budget_type = Budget

    Thank you
    Bobin

    That should do it.

    SELECT SUM (balance_amount),
           balance_type,
           balance_month
    FROM balance_table
    WHERE (balance_type = 'Actual'
           and balance_month <= :entered_month
          )
    or (balance_type = 'Budget'
        and balance_month > :entered_month
        and budget_name = :entered_budget_name
       )
    GROUP BY balance_type,
             balance_month
    ORDER BY 2
    

    See you soon
    Sarma.

  • Case mix with Nested ifs statement

    Hello I need to mix a case statement with a few nested ifs, but I get an error I do not know how to start or complete the case statement. I've shortened the statement FOR readability

    Here is the code:

    < tt >

    BEGIN

    FOR events IN (SELECT EBA_CA_EVENTS. EVENT_NAME, EBA_CA_EVENTS. EVENT_ID,...)

    LOOP

    If the events. TYPE_ID <>(32230291965131516245569156552736940921) AND to_date (SYSDATE) = ((to_date (to_char (events. ((EVENT_DUE_DATE, "DD-MON-YYYY HH24:MI:SS"), "HH24:MI:SS MON-DD-YYYY"))-events. EVENT_NOT1)

    THEN

    Dbms_output.put_line ('adjustments of the SEND E-MAIL Alert 1 "criteria);

    on the other

    If the events. TYPE_ID = (32230291965131516245569156552736940921) and nvl(events.COMPLETED_MAIL_SENT,0) <>room ')

    THEN

    Dbms_output.put_line ('SEND EMAIL FILLED WITH TERRY');

    UPDATE EBA_CA_EVENTS set COMPLETED_MAIL_SENT = piece ') where ROW_KEY = events. ROW_KEY;

    on the other

    If the events. TYPE_ID <>(32230291965131516245569156552736940921) AND to_date (SYSDATE) = ((to_date (to_char (events. ((EVENT_DUE_DATE, "DD-MON-YYYY HH24:MI:SS"), "HH24:MI:SS MON-DD-YYYY"))-events. EVENT_NOT2)

    THEN

    Dbms_output.put_line (' fits the criteria 2nd SEND E-MAIL alert 2 "");

    on the other

    If the events. TYPE_ID <>(32230291965131516245569156552736940921) AND to_date (SYSDATE) = ((to_date (to_char (events. ((EVENT_DUE_DATE, "DD-MON-YYYY HH24:MI:SS"), "HH24:MI:SS MON-DD-YYYY"))-events. EVENT_NOT3)

    THEN

    Dbms_output.put_line ('fits the 3rd criteria SENDING E-MAIL Alert 3 ");

    end if; -4

    end if; -3

    end if; -2

    end if; -1

    CASE

    Events WHEN. EVENT_NOT2 is null

    THEN

    If to_date (SYSDATE) > ((to_date (to_char (events. ((EVENT_DUE_DATE, "DD-MON-YYYY HH24:MI:SS"), "HH24:MI:SS MON-DD-YYYY"))-events. EVENT_NOT1) AND nvl (events. ALERT1_SENT, 0) part <>')

    THEN

    Dbms_output.put_line ('send e-mail if day part 1');

    UPDATE EBA_CA_EVENTS set ALERT1_SENT = piece ') where ROW_KEY = events. ROW_KEY;

    end if;

    END

    other cases

    Events WHEN. EVENT_NOT2 is NOT NULL

    THEN

    If to_date (SYSDATE) > ((to_date (to_char (events. ((EVENT_DUE_DATE, "DD-MON-YYYY HH24:MI:SS"), "HH24:MI:SS MON-DD-YYYY"))-events. EVENT_NOT1) AND nvl (events. ALERT1_SENT, 0) part <>') AND to_date (SYSDATE) < ((to_date (to_char (events. ((EVENT_DUE_DATE, "DD-MON-YYYY HH24:MI:SS"), "HH24:MI:SS MON-DD-YYYY"))-events. EVENT_NOT2)

    THEN

    Dbms_output.put_line ('If day spent game 2 with the value');

    UPDATE EBA_CA_EVENTS set ALERT1_SENT = piece ') where ROW_KEY = events. ROW_KEY;

    end if;

    END

    END LOOP;

    END

    < /tt >

    The error occurs towards the end of the case statement-case.PNG

    I also tried this the 'else' deletion before the case and a few other variations, I can't just not perfect the code however, any help would be appreciated, thanks

    BTW, I can't use IF... Logical I already tried, then once a particular branch occurs then the else statements are ignored.

    You had an extra 'END' where he shouldn't have been and were not an 'END' where TI EXPECTED have been.

    This is your modified code (I had to fill out the... that my trainer Toad worked properly)

    BEGIN
    
       FOR EVENTS IN (
                      SELECT eba_ca_events.event_name, eba_ca_events.event_id
                        FROM 
                     ) LOOP
    
          IF(
             EVENTS.type_id <> (32230291965131516245569156552736940921)
             AND
             TO_DATE(SYSDATE) = ((TO_DATE(TO_CHAR(EVENTS.event_due_date, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS') - EVENTS.event_not1))
            ) THEN
    
             DBMS_OUTPUT.PUT_LINE('Criteria fits SEND EMAIL Alert 1');
    
          ELSE
    
             IF(
                EVENTS.type_id = (32230291965131516245569156552736940921)
                AND
                NVL(EVENTS.completed_mail_sent, 0) <> ('S')
               )
                 THEN
    
                DBMS_OUTPUT.PUT_LINE('SEND COMPLETED EMAIL TO TERRY');
    
                UPDATE eba_ca_events
                   SET completed_mail_sent = ('S')
                 WHERE row_key = EVENTS.row_key;
    
             ELSE
    
                IF(
                   EVENTS.type_id <> (32230291965131516245569156552736940921)
                    AND
                    TO_DATE(SYSDATE) = ((TO_DATE(TO_CHAR(EVENTS.event_due_date, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS')) - EVENTS.event_not2)
                  ) THEN
    
                   DBMS_OUTPUT.PUT_LINE('2nd Criteria fits SEND EMAIL Alert 2');
    
                ELSE
    
                   IF(
                      EVENTS.type_id <> (32230291965131516245569156552736940921)
                      AND
                      TO_DATE(SYSDATE) = ((TO_DATE(TO_CHAR(EVENTS.event_due_date, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS')) - EVENTS.event_not3)
                     ) THEN
    
                      DBMS_OUTPUT.PUT_LINE('3rd Criteria fits SEND EMAIL Alert 3');
    
                   END IF; -- 4
    
                END IF; -- 3
    
             END IF; -- 2
    
          END IF; -- 1
    
          CASE
    
             WHEN EVENTS.event_not2 IS NULL THEN
    
                IF(
                   TO_DATE(SYSDATE) > ((TO_DATE(TO_CHAR(EVENTS.event_due_date, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS')) - EVENTS.event_not1)
                   AND
                   NVL(EVENTS.alert1_sent, 0) <> ('S')
                  ) THEN
    
                   DBMS_OUTPUT.PUT_LINE(' send email if date past part 1');
    
                   UPDATE eba_ca_events
                      SET alert1_sent = ('S')
                    WHERE row_key = EVENTS.row_key;
    
                END IF;
    
             ELSE
    
                CASE
    
                   WHEN EVENTS.event_not2 IS NOT NULL THEN
    
                      IF(
                         TO_DATE(SYSDATE) > ((TO_DATE(TO_CHAR(EVENTS.event_due_date, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS')) - EVENTS.event_not1)
                         AND
                         NVL(EVENTS.alert1_sent, 0) <> ('S')
                         AND
                         TO_DATE(SYSDATE) < ((TO_DATE(TO_CHAR(EVENTS.event_due_date, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS')) - EVENTS.event_not2)
                        ) THEN
    
                         DBMS_OUTPUT.PUT_LINE('if date past part 2 with value');
    
                         UPDATE eba_ca_events
                            SET alert1_sent = ('S')
                          WHERE row_key = EVENTS.row_key;
    
                      END IF;
    
                END CASE;
    
          END CASE;
    
       END LOOP;
    
    END;
    

    I hope this helps.

  • Excel and the CASE statement.

    Hello Experts,

    I use a CASE statement on the column of CHAR type as follows:

    CASE WHEN Sales.Ret = 'Y' THEN 'Return' END of OTHER 'new '.

    It gives an error: Odbc driver returned an error (SQLExecDirectW).

    Whereas, when I use another CASE statement with column Numrical it works perfectly.
    CASE WHEN Sales.Amount < END If NOT 100 40 THEN 40

    Am I missing an Excel data source definition related to the CHAR data type?

    My source is MS Excel 2003 and OBIEE 10.1.3.4.1

    Thank you for any comments, help.

    ~ Ash

    PS: the details of the error are the following:*.
    Error codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 16001] ODBC error state: 37000 code:-3100 message: error [Microsoft] [ODBC Excel Driver] syntax (missing operator) in query expression ' case when T46. [Retirement] = "Y" then "known" other "new" end "... [nQSError: 16014] Prepare the SQL statement failed. (HY000)
    Publ. SQL: SELECT Sales.Tran_date, saw_0, CASE WHEN Sales.Ret = 'Y' THEN 'Return' ELSE 'New' END saw_1, network. "" Network name "saw_2, Sales.Amount saw_3 FROM P4UD ORDER BY saw_0, saw_1, saw_2

    Sorry, the button is 'Ask DBMS' (biee 10g)

  • Case statement for aging buckets

    OBIEE 11 g. I am trying to create a case statement with aging buckets. Tried in the frontend and the RPD, but on the first bucket made its appearance. (1-30 days old). The other 3 buckets do not appear.

    30 - 60 days old

    60 - 90 days old

    90 - 120 days old

    There are dates in the database who meet the criteria for the other 3 buckets. This is the case statement.

    
    

    use the below the formula instead of what you pasted...

    cases where "Date of creation". ' ' Created Date ' > = TIMESTAMPADD (SQL_TSI_DAY-30, CURRENT_DATE) then 1-30 days old '

    When "Date Created". " Created Date' <= timestampadd(sql_tsi_day,="" -30,="" current_date="" )="" and="" "created="" date"."created="" date"="">= TIMESTAMPADD (SQL_TSI_DAY,-60, CURRENT_DATE) then 30-60 days old '

    When "Date Created". " Created Date' <= timestampadd(sql_tsi_day,="" -60,="" current_date="" )="" and="" "created="" date"."created="" date"="">= TIMESTAMPADD (SQL_TSI_DAY,-90, CURRENT_DATE) then from 60 to 90 days old '

    When "Date Created". " "Created Date" <= timestampadd(sql_tsi_day,="" -90,="" current_date="" )="" and="" "created="" date"."created="" date"="">= TIMESTAMPADD (SQL_TSI_DAY,-120, CURRENT_DATE) then 90-120 days old ' end

    Thank you

    AJ

  • Select with case statement and a formula of the IIR

    Hi, I was looking to get help regarding a statement writing box with a statement select statement all. I tried to reproduce a formula IIf access well that just wanted to check that the query I wrote is correct, any advice would be appreciated.

    [code]

    Select *.

    Of

    (

    Select name, month, duration, volume, time_spent, date1, date2,.

    -case when 'date' > = 'date1' then '1' other '0' end as departure,.

    -case when 'date' < = "date2" then '1' other '0' as end ending

    Of

    (

    Select *.

    of call_1 cd

    inner join call_2 ON cd.name = cl.queue cl

    )

    )

    ;

    [/ code]

    I want to know is where I have my ' select name, etc, I would change that to select * to make it easier instead of typing all the field_names outside, but I don't know how to do and also what follows is 2 IIF formulas from an access database for the start of the final case statements so I just wanted check I wrote it correctly.

    [code]

    departure: IIf ([date] > = [date1], 1, 0)

    [/ code]

    [code]

    ending: IIf ([date] < = [date2], 1, 0)

    [/ code]

    Any advice would be appreciated.

    Hello

    Whenever you have any questions, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
    Explain, using specific examples, how you get these results from these data.

    If the output depends on what anyone outside the application itself (for example, when it is run) and then include a few different examples and the results you want of each given the same sample data. For example, "if I run on November 19, 2013, while the results should be... because... but if I run between November 21 and November 27, then the results should be... because...". »
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

    318f20b8-a3d0-4FB4-bb0f-73785250b7d4 wrote:

    Hi, I was looking to get help regarding a statement writing box with a statement select statement all. I tried to reproduce a formula IIf access well that just wanted to check that the query I wrote is correct, any advice would be appreciated.

    [code]

    Select *.

    Of

    (

    Select name, month, duration, volume, time_spent, date1, date2,.

    -case when 'date' > = 'date1' then '1' other '0' end as departure,.

    -case when "date."<= 'date2'="" then="" '1'="" else="" '0'="" end="" as="">

    Of

    (

    Select *.

    of call_1 cd

    inner join call_2 ON cd.name = cl.queue cl

    )

    )

    ;

    [/ code]

    I want to know is where I have my ' select name, etc, I would change that to select * to make it easier instead of typing all the field_names outside, but I don't know how to do and also what follows is 2 IIF formulas from an access database for the start of the final case statements so I just wanted check I wrote it correctly.

    [code]

    departure: IIf([date]>=[date1],1,0)

    [/ code]

    [code]

    ending: IIf ([date]<>

    [/ code]

    Any advice would be appreciated.

    DATE is not a function of Oracle; in fact, it's a terrible name for a column or function, because it blends with the DATE data type.

    In Oracle, the function SYSDATE returns the date and time, according to the clock on the database server.  So, SYSDATE can return a value as November 19, 2013 06:33:15.   If you want to midnight the same day (i.e., November 19, 2013 00:00:00) and then use TRUNC (SYSDATE).

    String literals (for example the string which consists 5 characters d, a, t, e, and 1) go inside the single quotes. Numbers and the names of columns only.

    If you want to include all the columns, more some calculated values, in a SELECT clause, then you must use a name table or alias before the *.  (See select_2 below.  To do this, assign the alias j to display online.)

    Maybe you wanted to say something like:

    Select *-it's select_1

    de)

    Select j. *-it's select_2

    , case when SYSDATE > = date1 then 1 or 0 end as departure

    , case when SYSDATE<= date2="" then="" 1="" else="" 0="" end="" as="">

    de)

    Select *-it's select_3

    of call_1 cd

    inner join call_2 ON cd.name = cl.queue cl

    ) j

    )

    ;

    As mentioned in a previous answer, you should be careful about the use of "SELECT *" in production code.

    In select_3, it would be better if you explicitly listed the columns you need.  It can improve efficiency and maintenance.  In this request, queue and the name will be always the same, so you probably don't want to include both of them in the result set, in any case.

    In select_1 and select_2, it is acceptable to use "SELECT *", assuming that select_3 is fixed.

    Moreover, there is no point in using subqueries here.  You can get the same results simply in a single query, without any subqueries.

  • definition of variables in packages and using the same variables in charge Plans as a case statement in Odi

    Hello

    I am trying to use a global variable 'Global.test' in my ODI "pkg_test" package and step declaration type as a variable that is defined with the value 1 when my package evaluates the condition successfully run and with 0 if the fails.now condition I will carry out the same "pkg_test" package in my load "LP_TEST" and using the variable 'Global.test' Plan as a case statement in terms of load "LP_TEST".

    It's workload Odi is unable to understand the value of the variable 'Global.test', which is defined in my pkg 'pkg_test' and my case statement is put down in my care Plan.

    Thank you

    Hi Santosh Pradhan,

    What kind of story do you have in your variable?

    If you have not selected any antecedent, the scope of the variable is limited to the session. As the execution of the package is a session in its own (independent of the workload performance), the value of the variable is not accessible after his execution.

    You can also try assigning / updating of the value of the variable directly from your plan, instead of in the package:

    It will be useful.

    Best regards

    JeromeFr

  • Problem with CASE statements

    Hi all

    I have a calculation in a report of Discoverer Desktop with 29 instructions BOX and still 2 case statements more to add. The problem is that my report freezes and fails to run due to the excessive number of case statements. I need to put the 31 statemnts cases in the report, how do I do this? Is there another way to do it without causing the report to freeze?

    Below is part of my instructions box just to show you what I'm doing:

    CASE WHEN Ex = 'MM' AND THEN of OTHER NULL result (', ')
    CASES WHERE Ex = "PP" AND result IN (40,35,30,25) THEN NULL OTHERWISE
    CASE WHEN Ex = he's ' AND result IN (' a ',' B', 'C', d ') THEN NULL OTHERWISE
    -CASE WHEN Ex = 'IO' AND THEN of OTHER NULL result ('Distinction', 'Merit')
    -CASE WHEN Ex IN ('ZZ', 'WW', 'SS', 'KK') AND ('PASS', 'P') THEN to ANOTHER NULL result...

    The last statement should be BOX WHEN... THEN NULL OTHERWISE 1 END END END END...

    Help, please. Thank you.

    Hello
    You have reached the limit of characters in a calculation.

    Try to set into a single statement as follows:

    CASE WHEN Ex = 'MM' AND THEN of OTHER NULL result (', ')
    WHEN Ex = "PP" AND as a result (40,35,30,25) THEN NULL OTHERWISE
    WHEN Ex = he's ' AND result IN (' a ',' B', 'C', d ') THEN NULL OTHERWISE
    WHEN Ex = 'IO' AND THEN of OTHER NULL result ('Distinction', 'Merit')
    WHEN Ex IN ('ZZ', 'WW', 'SS', 'KK') AND ('PASS', 'P') THEN to ANOTHER NULL result...

    The last statement should be BOX WHEN... THEN NULL OTHERWISE 1 END

    Another option is to combine all the statements of NULL in a series of gold options like this:

    BOX WHEN
    (Ex = 'MM' AND the result in (', am')) OR
    (Ex = "PP" AND result IN (40,35,30,25)) OR
    (Ex = he's ' AND translated BY (' a ',' B', 'C', ')) OR
    (Ex = 'IO' AND as a result ('Distinction', "according to merit")) OR
    (Ex IN ("ZZ", "WW", "SS", "KK") AND result IN ('PASS', 'P')) THEN ANOTHER NULL...

    Best wishes
    Michael

Maybe you are looking for