Using case when statement in the select query to create physical table

Hello,
I have a requirement where in I have to execute a case when statement with a session variable while creating a physical table using a select query. let me explain with an example.
I have a physical table based on a select table with one column.
SELECT 'VALUEOF(NQ_SESSION.NAME_PARAMETER)' AS NAME_PARAMETER FROM DUAL. Let me call this table as the NAME_PARAMETER table.
I also have a customer table.
In my dashboard that has two pages, Page 1 contains a table with the customer table with column navigation to my second dashboard page.
In my second dashboard page I created a dashboard report based on NAME_PARAMETER table and a prompt based on customer table that sets the NAME_ PARAMETER request variable.
EXECUTION
When i click on a particular customer, the prompt sets the variable NAME_PARAMETER and the NAME_PARAMETER table shows the appropriate customer.
everything works as expected. YE!!
Now i created another table called NAME_PARAMETER1 with a little modification to the earlier table. the query is as follows.
SELECT CASE WHEN 'VALUEOF(NQ_SESSION.NAME_PARAMETER)'='Customer 1' THEN 'TEST_MART1' ELSE TEST_MART2' END AS NAME_PARAMETER
FROM DUAL
Now I pull in this table into the second dashboard page along with the NAME_PARAMETER table report.
surprisingly, NAME_PARAMETER table report executes as is, but the other report based on the NAME_PARAMETER1 table fails with the following error.
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 16001] ODBC error state: S1000 code: 1756 message: [Oracle][ODBC][Ora]ORA-01756: quoted string not properly terminated. [nQSError: 16014] SQL statement preparation failed. (HY000)
SQL Issued: SET VARIABLE NAME_PARAMETER='Novartis';SELECT NAME_PARAMETER.NAME_PARAMETER saw_0 FROM POC_ONE_DOT_TWO ORDER BY saw_0
If anyone has any explanation to this error and how we can achieve the same, please help.
Thanks.

Hello,
Updates :) sorry.. the error was a stupid one.. I resolved and I got stuck at my next step.
I am creating a physical table using a select query. But I am trying to obtain the name of the table dynamically.
Here is what I am trying to do. the select query of the physical table is as follows.
SELECT CUSTOMER_ID AS CUSTOMER_ID, CUSTOMER_NAME AS CUSTOMER_NAME FROM 'VALUEOF(NQ_SESSION.SCHEMA_NAME)'.CUSTOMER.
The idea behind this is to obtain the data from the same table from different schemas dynamically based on what a session variable. Please let me know if there is a way to achieve this, if not please let me know if this can be achieved in any other method in OBIEE.
Thanks.

Similar Messages

  • Using case when statement or decode stament in where clause

    hi gems..
    i have a problem in the following query..
    i am trying to use case when statement in the where clause of a select query.
    select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
    cr.salary as salary
    from customer_details cr
    where (case when '>' = '>' then 'cr.salary > 5000'
    when '>' = '<' then 'cr.salary < 5000'
    when '>' = '=' then 'cr.salary = 5000'
    else null
    end);
    the expression in the when clause of the case-when statement will come from UI and depending on the choice i need to make the where clause.
    thats why for running the query, i have put '>' in that place.
    so the original query will look like this(for your reference):
    select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
    cr.salary as salary
    from customer_details cr
    where (case when variable = '>' then 'cr.salary > 5000'
    when variable = '<' then 'cr.salary < 5000'
    when variable = '=' then 'cr.salary = 5000'
    else null
    end);
    so, in actual case,if the user selects '>' then the filter will be "where cr.salary > 5000"
    if the user selects '<' then the filter will be "where cr.salary < 5000"
    if the user selects '=' then the filter will be "where cr.salary = 5000"
    but i am getting the error "ORA 00920:invalid relational operator"
    please help..thanks in advance..

    Hi,
    select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
           cr.salary                                      as salary
    from customer_details cr
    where (    v_variable = 'bigger'
           and cr.salary > 5000
       or (    v_variable = 'less'
          and cr.salary < 5000
       or (    v_variable = 'eq'
            and cr.salary = 5000
           )Edited by: user6806750 on 22.12.2011 14:56
    For some reason I can't write in sql '<', '>', '='

  • How can I use an IF statement in the SELECT

    Hi People,
    I have a procedure called ENQUEUE_PROC which takes 3 parameters.
    and I am trying to use an if statement in the select. I appreciate the help with this task.
    here is my code.
    Please have a look at my Select statement. What I have does not compile, however it might give you an idea of what i need.
    PROCEDURE ENQUEUE_PROC(P_SUBMISSION_ID NUMBER,
                           P_EVENT         VARCHAR2,
                                CASE_TYPE_CODE NUMBER;
                           ) AS
         XMLDATA XMLTYPE;
         enqueue_options     dbms_aq.enqueue_options_t;
         message_properties  dbms_aq.message_properties_t;
         message_handle      RAW(16);
         message SYS.AQ$_JMS_TEXT_MESSAGE;
    BEGIN
              SELECT      
                        XMLELEMENT("caseFileEvent", XMLATTRIBUTES('http://www.ussc.gov/soa/casefile/event/types' AS "xmlns",
                                                          'http://www.ussc.gov/soa/casefile/event/types' AS "xmlns:ns0"),
                             XMLELEMENT("caseFileUploadEvent", XMLATTRIBUTES('http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi",
                                                                                                   'http://www.ussc.gov/soa/casefile/event/types ../xsd/Case_META.xsd' AS "xsi:schemaLocation",
                                                                                                   'http://www.ussc.gov/soa/casefile/event/types' AS "xmlns"),
                                       XMLELEMENT("taskEvent", P_EVENT), --eg - 'SUBMIT', 'REJECT', 'RESUBMIT'
                                XMLELEMENT("defendentDetails",
                                                                XMLELEMENT("sentensingDate", SMD.SENT_VIO_DATE),
                                                                XMLELEMENT("personDetails",
                                                                               // Here is where I want my IF statement, *********************************
                                                                               IF CASE_TYPE_CODE = 10 THEN
                                                                                         XMLELEMENT("personNameDetails",
                                                                                                             XMLELEMENT("firstName", SMD.FIRST_NAME),
                                                                                                             XMLELEMENT("middleName", SMD.MIDDLE_NAME),
                                                                                                             XMLELEMENT("lastName", SMD.LAST_NAME)
                                                                                                   ), -- personNameDetails
                                                                               ELSE
                                                                                    XMLELEMENT("personNameDetails",
                                                                                                   XMLELEMENT("corpname", SMD.CORPNAME),
                                                                                         ), -- personNameDetails
                                                                               XMLELEMENT("dateOfBirth", SMD.BIRTH_DATE)          
                                                                          ) -- personDetails
                                            ), -- defendentDetails
                                            XMLELEMENT("documentStatusDetails",
                                                      XMLELEMENT("otherStatus",
                                                                     XMLELEMENT("intCode", NULL),
                                                                     XMLELEMENT("description", NULL)
                                                                ) -- otherStatus
                                            ), -- documentStatusDetails
                                            XMLELEMENT("uploadOtherDetails",
                                                           XMLELEMENT("submissionId", SUB.SUBMISSION_ID),
                                                           XMLELEMENT("submissionSessionId", SUB.SUB_SESSION_ID),
                                                           XMLELEMENT("submissionMethod",
                                                                XMLELEMENT("intCode", SUB.SUB_MTHD_CODE),
                                                                XMLELEMENT("description", SM.DESCRIP)
                                                           ), -- submissionMethod
                                                           XMLELEMENT("submissionReason",
                            XMLELEMENT("intCode", SUB.SUB_TYPE_CODE),
                                                                XMLELEMENT("description", SR.DESCRIP)
                                                           ), -- submissionReason
                                                           XMLELEMENT("district",
                                                                XMLELEMENT("intCode", SMD.DIST_ID),
                                                                XMLELEMENT("description", D.DISTRICT_NAME)
                                                           ), -- district
                                                           XMLELEMENT("caseFileType",
                                                                XMLELEMENT("intCode", SUB.CASE_TYPE_CODE),
                                                                XMLELEMENT("description", C.DESCRIP)
                                                           ), -- caseFileType
                                                           XMLELEMENT("primaryDocketInfo",
                                                                XMLELEMENT("yearYY", SUBSTR(SMD.DOCKET, 1, 2)),
                                                                XMLELEMENT("id", SUBSTR(SMD.DOCKET, 3, 7)),
                                                                XMLELEMENT("defendentNumber", SMD.DEF_NUM)
                                                           ), -- primaryDocketInfo
                                                           XMLELEMENT("PACTSId", SMD.PACTS_ID), -- PACTSId
                                                           XMLELEMENT("AOJudgeId",
                                                                XMLELEMENT("intCode", SMD.AO_JUDGE_ID),
                                                                XMLELEMENT("description", J.LAST_NAME || ', ' || J.FIRST_NAME || ', ' || J.MIDDLE_NAME)
                                                           ), -- AOJudgeId
                                                           XMLELEMENT("missingCasefile", SUB.MISSING_CASE), -- missingCasefile
                                                           XMLELEMENT("creator",
                                                                XMLELEMENT("firstName", NULL),
                                                                XMLELEMENT("lastName", NULL),
                                                                XMLELEMENT("email", SUB.CREATOR_ID),
                                                                XMLELEMENT("actionDate", REGEXP_REPLACE( TO_CHAR(SUB.CREATE_TIME, 'YYYY-MM-DD"T"HH24:MI:SS.FFTZR'), '...(......)$', '\1'))
                                                           ), -- creator
                                                           XMLELEMENT("lastModifier",
                                                                XMLELEMENT("firstName", NULL),
                                                                XMLELEMENT("lastName", NULL),
                                                                XMLELEMENT("email", H.USER_ID),
                                                                XMLELEMENT("actionDate", TO_CHAR(H.ACTION_DATE, 'YYYY-MM-DD"T"HH24:MI:SS".000-05:00"'))
                                                           ) -- lastModifier
                                            ) -- uploadOtherDetails
                             ) -- caseFileUploadEvent
                        ) -- caseFileEvent
              INTO      XMLDATA
              FROM      USSC_CASES.SUBMISSION SUB,
              USSC_CASES.SUBMISSION_METADATA SMD,
              USSC_CASES.CASE_HISTORY H,
              LOOKUP.CASE_SUB_MTHD SM,
              LOOKUP.CASE_SUB_TYPE SR,
              LOOKUP.DISTRICTS D,
              LOOKUP.JUDGES J,
              LOOKUP.CASE_TYPES C
              WHERE      SUB.SUBMISSION_ID = SMD.SUBMISSION_ID
              AND        SUB.SUBMISSION_ID = H.SUBMISSION_ID
              AND        SUB.SUB_MTHD_CODE = SM.SUBMTHD_CODE
              AND        SUB.SUB_TYPE_CODE = SR.SUBTYPE_CODE
              AND        SUB.CASE_TYPE_CODE = C.CASE_TYPE_CODE
              AND        SMD.DIST_ID = D.USSC_DISTRICT_ID
              AND        SMD.AO_JUDGE_ID = J.AO_JUDGE_ID
              AND        H.ACTION_DATE IN (SELECT MAX(A.ACTION_DATE)
                                  FROM USSC_CASES.CASE_HISTORY A
                                  WHERE A.SUBMISSION_ID = P_SUBMISSION_ID)
              AND        SUB.SUBMISSION_ID = P_SUBMISSION_ID;
        --dbms_output.put_line('queue start '|| xmldata.getclobval());
        --insert into test1 values(xmldata);
        message := SYS.AQ$_JMS_TEXT_MESSAGE.construct;
        message.set_text(xmldata.getStringVal());
        DBMS_AQ.ENQUEUE(queue_name => 'case_file_queue',  -- aqadm.cases_queue             
        enqueue_options    => enqueue_options,       
        message_properties => message_properties,     
        payload  => message,             
        msgid   => message_handle);
         COMMIT;
    END ENQUEUE_PROC;

    thanks for the help,
    I believe I almost got it to compilw, however I am getting Error(29,19): PL/SQL: ORA-00918: column ambiguously defined.
    Of course CASE_TYPE_CODE is ambiguously because its passed in, is there a way around this.
    Here is what i have so far.
    PROCEDURE ENQUEUE_PROC(P_SUBMISSION_ID NUMBER,
                           P_EVENT         VARCHAR2,
                           CASE_TYPE_CODE NUMBER    // passed in field
                           ) AS
         XMLDATA XMLTYPE;
         enqueue_options     dbms_aq.enqueue_options_t;
         message_properties  dbms_aq.message_properties_t;
         message_handle      RAW(16);
         message SYS.AQ$_JMS_TEXT_MESSAGE;
    BEGIN
              SELECT      
                        XMLELEMENT("caseFileEvent", XMLATTRIBUTES('http://www.ussc.gov/soa/casefile/event/types' AS "xmlns",
                                                          'http://www.ussc.gov/soa/casefile/event/types' AS "xmlns:ns0"),
                             XMLELEMENT("caseFileUploadEvent", XMLATTRIBUTES('http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi",
                                                                                                   'http://www.ussc.gov/soa/casefile/event/types ../xsd/Case_META.xsd' AS "xsi:schemaLocation",
                                                                                                   'http://www.ussc.gov/soa/casefile/event/types' AS "xmlns"),
                                       XMLELEMENT("taskEvent", P_EVENT), --eg - 'SUBMIT', 'REJECT', 'RESUBMIT'
                                            XMLELEMENT("defendentDetails",
                                                                XMLELEMENT("sentensingDate", SMD.SENT_VIO_DATE),
                                                                CASE
                                                                     WHEN CASE_TYPE_CODE = 10 THEN
                                                                           XMLELEMENT("personDetails",
                                                                                         XMLELEMENT("personNameDetails",
                                                                                                             XMLELEMENT("firstName", SMD.FIRST_NAME),
                                                                                                             XMLELEMENT("middleName", SMD.MIDDLE_NAME),
                                                                                                             XMLELEMENT("lastName", SMD.LAST_NAME)
                                                                                                   ), -- personNameDetails 
                                                                                         XMLELEMENT("dateOfBirth", SMD.BIRTH_DATE)          
                                                                                    ) -- personDetails
                                                                     ELSE
                                                                          XMLELEMENT("corporationDetails",
                                                                                         XMLELEMENT("organizationName", SMD.CORP_NAME)
                                                                                    ) -- corporationDetails          
                                                                END
                                            ), -- defendentDetails
                                            XMLELEMENT("documentStatusDetails",
                                                      XMLELEMENT("otherStatus",
                                                                     XMLELEMENT("intCode", NULL),
                                                                     XMLELEMENT("description", NULL)
                                                                ) -- otherStatus
                                            ), -- documentStatusDetails
                                            XMLELEMENT("uploadOtherDetails",
                                                           XMLELEMENT("submissionId", SUB.SUBMISSION_ID),
                                                           XMLELEMENT("submissionSessionId", SUB.SUB_SESSION_ID),
                                                           XMLELEMENT("submissionMethod",
                                                                XMLELEMENT("intCode", SUB.SUB_MTHD_CODE),
                                                                XMLELEMENT("description", SM.DESCRIP)
                                                           ), -- submissionMethod
                                                           XMLELEMENT("submissionReason",
                                                                XMLELEMENT("intCode", SUB.SUB_TYPE_CODE),
                                                                XMLELEMENT("description", SR.DESCRIP)
                                                           ), -- submissionReason
                                                           XMLELEMENT("district",
                                                                XMLELEMENT("intCode", SMD.DIST_ID),
                                                                XMLELEMENT("description", D.DISTRICT_NAME)
                                                           ), -- district
                                                           XMLELEMENT("caseFileType",
                                                                XMLELEMENT("intCode", SUB.CASE_TYPE_CODE),
                                                                XMLELEMENT("description", C.DESCRIP)
                                                           ), -- caseFileType
                                                           XMLELEMENT("primaryDocketInfo",
                                                                XMLELEMENT("yearYY", SUBSTR(SMD.DOCKET, 1, 2)),
                                                                XMLELEMENT("id", SUBSTR(SMD.DOCKET, 3, 7)),
                                                                XMLELEMENT("defendentNumber", SMD.DEF_NUM)
                                                           ), -- primaryDocketInfo
                                                           XMLELEMENT("PACTSId", SMD.PACTS_ID), -- PACTSId
                                                           XMLELEMENT("AOJudgeId",
                                                                XMLELEMENT("intCode", SMD.AO_JUDGE_ID),
                                                                XMLELEMENT("description", J.LAST_NAME || ', ' || J.FIRST_NAME || ', ' || J.MIDDLE_NAME)
                                                           ), -- AOJudgeId
                                                           XMLELEMENT("missingCasefile", SUB.MISSING_CASE), -- missingCasefile
                                                           XMLELEMENT("creator",
                                                                XMLELEMENT("firstName", NULL),
                                                                XMLELEMENT("lastName", NULL),
                                                                XMLELEMENT("email", SUB.CREATOR_ID),
                                                                XMLELEMENT("actionDate", REGEXP_REPLACE( TO_CHAR(SUB.CREATE_TIME, 'YYYY-MM-DD"T"HH24:MI:SS.FFTZR'), '...(......)$', '\1'))
                                                           ), -- creator
                                                           XMLELEMENT("lastModifier",
                                                                XMLELEMENT("firstName", NULL),
                                                                XMLELEMENT("lastName", NULL),
                                                                XMLELEMENT("email", H.USER_ID),
                                                                XMLELEMENT("actionDate", TO_CHAR(H.ACTION_DATE, 'YYYY-MM-DD"T"HH24:MI:SS".000-05:00"'))
                                                           ) -- lastModifier
                                            ) -- uploadOtherDetails
                             ) -- caseFileUploadEvent
                        ) -- caseFileEvent
              INTO      XMLDATA
              FROM      USSC_CASES.SUBMISSION SUB,
              USSC_CASES.SUBMISSION_METADATA SMD,
              USSC_CASES.CASE_HISTORY H,
              LOOKUP.CASE_SUB_MTHD SM,
              LOOKUP.CASE_SUB_TYPE SR,
              LOOKUP.DISTRICTS D,
              LOOKUP.JUDGES J,
              LOOKUP.CASE_TYPES C
              WHERE      SUB.SUBMISSION_ID = SMD.SUBMISSION_ID
              AND        SUB.SUBMISSION_ID = H.SUBMISSION_ID
              AND        SUB.SUB_MTHD_CODE = SM.SUBMTHD_CODE
              AND        SUB.SUB_TYPE_CODE = SR.SUBTYPE_CODE
              AND        SUB.CASE_TYPE_CODE = C.CASE_TYPE_CODE
              AND        SMD.DIST_ID = D.USSC_DISTRICT_ID
              AND        SMD.AO_JUDGE_ID = J.AO_JUDGE_ID
              AND        H.ACTION_DATE IN (SELECT      MAX(A.ACTION_DATE)
                                                 FROM      USSC_CASES.CASE_HISTORY A
                                                 WHERE      A.SUBMISSION_ID = P_SUBMISSION_ID)
              AND        SUB.SUBMISSION_ID = P_SUBMISSION_ID;
        --dbms_output.put_line('queue start '|| xmldata.getclobval());
        --insert into test1 values(xmldata);
        message := SYS.AQ$_JMS_TEXT_MESSAGE.construct;
        message.set_text(xmldata.getStringVal());
        DBMS_AQ.ENQUEUE(queue_name => 'case_file_queue',  -- aqadm.cases_queue             
        enqueue_options    => enqueue_options,       
        message_properties => message_properties,     
        payload  => message,             
        msgid   => message_handle);
         COMMIT;
    END ENQUEUE_PROC;Edited by: Rooney on Jan 31, 2012 1:55 PM

  • How to use case when statements in ODI

    I need to put conditional logic before DVM look up in ODI. In the expression editor I put the following statement:-
    CASE WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='RCS' THEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME=EBIZ_CELL.CELL_DATA
    WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='FDC' THEN CONCAT(POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME,POC_JOURNAL_TEMP_SOURCE_TBL.BOOK_CODE)=EBIZ_CELL.CELL_DATA
    END
    It did not work,
    Under Operators ->All Executions, found the error:-
    905 : 42000 : java.sql.SQLException: ORA-00905: missing keyword
    The description in Session Task contained:-
    select     
         C1_JOURNAL_TEMPL
    from     APPS.POC_JOURNAL_TEMP_SOURCE_TBL POC_JOURNAL_TEMP_SOURCE_TBL, APPS.C$_0POC_JOURNAL_TEMP_TARGET_TB
    where     
         (1=1)
    And (CASE
    WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='RCS'
    THEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME=C2_CELL_DATA
    WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='FDC'
    THEN CONCAT(POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME,POC_JOURNAL_TEMP_SOURCE_TBL.BOOK_CODE)=C2_CELL_DATA
    END)
    Checked the above code in PL/SQL Developer but it gave errors.
    In PL/SQL developer tried to check a simple query using case-when but even that is giving errors in the case-when portion.
    The query is as follows:-
    select phase_code, accounting_period, sum(eff_cc) as BD_Eff_QTD
    from prj_detail
    where
    case POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME
    when 'EXT'
    then
    1
    when 'RAC'
    then
    2
    when 'XXX'
    then
    3
    else
    end
    I would like to know what is wrong with the above code.
    Please let me know what is the correct way of using case-when in PL/SQL as well as in ODI.

    Your ODI case statement and PL/SQL Case statement both looks confusing.
    You are writing case statement under where clause which is not a good practise. If you want to implement logic like-
    select a,b,c from <table>
    where
    when cond^n^ 1 then do 1
    when cond^n^ 2 then do 2
    then better you seperate your query for each filter and do a union, in other words-
    select a,b,c from <table>
    where cond^n^ 1
    union
    select a,b,c from <table>
    where cond^n^ 2
    If you are writing case staement to retrieve a value/column (EBIZ_CELL.CELL_DATA) then no need to include it under filter.
    ODI case for column EBIZ_CELL.CELL_DATA will be:
    CASE
    WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='RCS'
    THEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME
    WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='FDC'
    THEN CONCAT(POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME,POC_JOURNAL_TEMP_SOURCE_TBL.BOOK_CODE)
    END
    Pl/SQL query-
    select phase_code, accounting_period,
    case POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME
    when 'EXT'then 1
    when 'RAC' then 2
    when 'XXX' then 3
    else 'default value' --- (if no else needed then can also remove else part)
    end,
    sum(eff_cc) as BD_Eff_QTD
    from prj_detail
    Suggested as per what is understood, hope it helps.
    Edited by: 939451 on Jul 5, 2012 12:47 AM
    Edited by: 939451 on Jul 5, 2012 12:48 AM

  • Using Case when statement in catalog doesnt result in the correct sql

    I am running into an issue on my current project wherein, I am not able to see the correct formula in the physical query as I am seeing it in the logical query:
    Logical query:
    SET VARIABLE QUERY_SRC_CD='Report',SAW_SRC_PATH='/shared/Email/SFDC_InitRespTimel_Main';SELECT s_0, s_1, s_2, s_3, s_4, s_5 FROM (
    SELECT
    0 s_0,
    "CIN"."Calendar"."FIis Yr Nm" s_1,
    "CIN"."Calendar"."Fis Qtr Nm" s_2,
    "CIN"."SF Origin Dim"."Group" s_3,
    **CASE WHEN MIN("CIN"."SF_EailMsg_L"."Msg Dt") IS NOT NULL THEN SUM(TIMESTAMPDIFF(SQL_TSI_HOUR,MIN("SF_EailMsg_L"."Msg Dt"),"CIN"."SF_Case_L_Fact"."Created Dt"))/count("CIN"."SF_Case_L_Fact"."Case Number") END s_4,**
    **REPORT_AGGREGATE(CASE WHEN MIN("CIN"."SF_EailMsg_L"."Msg Dt") IS NOT NULL THEN SUM(TIMESTAMPDIFF(SQL_TSI_HOUR,MIN("SF_EailMsg_L"."Msg Dt"),"CIN"."SF_Case_L_Fact"."Created Dt"))/count("CIN"."SF_Case_L_Fact"."Case Number") END BY "CIN"."Calendar"."Fis Qtr Nm","CIN"."SF Origin Dim"."Group") s_5**
    FROM "CIN"
    WHERE
    (("Calendar"."FISCAL_YEAR_NAME" IN ('FY2011', 'FY2012', 'FY2013')) AND ("SF_EailMsg_L"."Status" = '3') AND ("Calendar"."FISCAL_QUARTER_NAME" <> 'Q1 FY2011'))
    ) djm ORDER BY 1, 2 ASC NULLS LAST, 3 ASC NULLS LAST, 4 ASC NULLS LAST
    Physical Query:
    select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4
    from
    (select T13596.CRTDDT_DT as c1,
    T4813.FISCAL_YEAR_NAME as c2,
    T4813.FISCAL_QUARTER_NAME as c3,
    T13313.GRP as c4,
    ROW_NUMBER() OVER (PARTITION BY T4813.FISCAL_QUARTER_NAME, T13313.GRP, T13596.CRTDDT_DT ORDER BY T4813.FISCAL_QUARTER_NAME ASC, T13313.GRP ASC, T13596.CRTDDT_DT ASC) as c5
    from
    DW_SF_EMLMSSG_L T13275,
    SF_ORGN_L_DIM T13313,
    CIN_CALENDARS_DIM T4813,
    DW_SF_CS_L T13596 /* SF_CS_L_Fact */
    where ( T4813.CALENDAR_KEY = T13596.CRDT_KEY and T13275.PRNTID = T13596.ID and T13275.STTS = '3' and T13313.ORGN_KEY = T13596.ORGN_KEY and (T4813.FISCAL_YEAR_NAME in ('FY2011', 'FY2012', 'FY2013')) and T4813.FISCAL_QUARTER_NAME <> 'Q1 FY2011' )
    ) D1
    where ( D1.c5 = 1 )
    WITH
    SAWITH0 AS (select min(T13275.MSSGDT_DT) as c1,
    count(T13596.CSNMBR) as c2,
    T4813.FISCAL_YEAR_NAME as c5,
    T4813.FISCAL_QUARTER_NAME as c6,
    T13313.GRP as c7
    from
    DW_SF_EMLMSSG_L T13275,
    SF_ORGN_L_DIM T13313,
    CIN_CALENDARS_DIM T4813,
    DW_SF_CS_L T13596 /* SF_CS_L_Fact */
    where ( T4813.CALENDAR_KEY = T13596.CRDT_KEY and T13275.PRNTID = T13596.ID and T13275.STTS = '3' and T13313.ORGN_KEY = T13596.ORGN_KEY and (T4813.FISCAL_YEAR_NAME in ('FY2011', 'FY2012', 'FY2013')) and T4813.FISCAL_QUARTER_NAME <> 'Q1 FY2011' )
    group by T4813.FISCAL_QUARTER_NAME, T4813.FISCAL_YEAR_NAME, T13313.GRP)
    select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4,
    D1.c5 as c5,
    D1.c6 as c6,
    D1.c7 as c7
    from
    (select D1.c1 as c1,
    D1.c2 as c2,
    min(D1.c1) over (partition by D1.c6, D1.c7) as c3,
    sum(D1.c2) over (partition by D1.c6, D1.c7) as c4,
    D1.c5 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    ROW_NUMBER() OVER (PARTITION BY D1.c6, D1.c7 ORDER BY D1.c6 ASC, D1.c7 ASC) as c8
    from
    SAWITH0 D1
    ) D1
    where ( D1.c8 = 1 )
    I want to know if you have seen this scenario earlier?
    Basically, the case statement in the logical sql is not getting executed correctly in the physical sql. Also,I see a SAWWITH0 in the query. Have you seen this before.
    If you have any inputs on how to fix this, please share.
    Thanks in advance.
    -Mayank Sharma

    Hello,
    This is the logical and physical query that I am getting now.
    My question is that, why am I not seeing the division operator (/) anywhere in the physical query. I am worried that the physical query is not being executed correctly.
    Please clarify:
    SET VARIABLE QUERY_SRC_CD='Report',SAW_DASHBOARD='/shared/Email/Email',SAW_DASHBOARD_PG='Initial Resp Time',SAW_SRC_PATH='/shared/Email/SFDC_InitRespTimel_Main';SELECT s_0, s_1, s_2, s_3, s_4, s_5 FROM (
    SELECT
    0 s_0,
    "CIN"."Calendar"."FIis Yr Nm" s_1,
    "CIN"."Calendar"."Fis Qtr Nm" s_2,
    "CIN"."SF Origin Dim"."Group" s_3,
    CASE WHEN MIN("CIN"."SF_EailMsg_L"."Msg Dt") IS NOT NULL THEN SUM(TIMESTAMPDIFF(SQL_TSI_HOUR,MIN("SF_EailMsg_L"."Msg Dt"),"CIN"."SF_Case_L_Fact"."Created Dt"))*1.0/count("CIN"."SF_Case_L_Fact"."Case Number")*1.0 END s_4,
    REPORT_AGGREGATE(CASE WHEN MIN("CIN"."SF_EailMsg_L"."Msg Dt") IS NOT NULL THEN SUM(TIMESTAMPDIFF(SQL_TSI_HOUR,MIN("SF_EailMsg_L"."Msg Dt"),"CIN"."SF_Case_L_Fact"."Created Dt"))*1.0/count("CIN"."SF_Case_L_Fact"."Case Number")*1.0 END BY "CIN"."Calendar"."Fis Qtr Nm","CIN"."SF Origin Dim"."Group") s_5
    FROM "CIN"
    WHERE
    (("Calendar"."FISCAL_YEAR_NAME" IN ('FY2011', 'FY2012', 'FY2013')) AND ("SF_EailMsg_L"."Status" = '3') AND ("Calendar"."FISCAL_QUARTER_NAME" <> 'Q1 FY2011'))
    ) djm ORDER BY 1, 2 ASC NULLS LAST, 3 ASC NULLS LAST, 4 ASC NULLS LAST
    [2012-10-25T22:20:58.000+00:00] [OracleBIServerComponent] [TRACE:2] [USER-23] [] [ecid: a5bccb33dce3bd12:-c49596b:13a898b42b5:-8000-0000000000007756] [tid: 601c] [requestid: 1d4c0001] [sessionid: 1d4c0000] [username: weblogic] -------------------- General Query Info: [[
    Repository: Star, Subject Area: CIN, Presentation: CIN
    [2012-10-25T22:20:58.000+00:00] [OracleBIServerComponent] [TRACE:2] [USER-18] [] [ecid: a5bccb33dce3bd12:-c49596b:13a898b42b5:-8000-0000000000007756] [tid: 601c] [requestid: 1d4c0001] [sessionid: 1d4c0000] [username: weblogic] -------------------- Sending query to database named CIN (id: <<177780>>), connection pool named CINADMIN: [[
    select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4
    from
    (select T13596.CRTDDT_DT as c1,
    T4813.FISCAL_YEAR_NAME as c2,
    T4813.FISCAL_QUARTER_NAME as c3,
    T13313.GRP as c4,
    ROW_NUMBER() OVER (PARTITION BY T4813.FISCAL_QUARTER_NAME, T13313.GRP, T13596.CRTDDT_DT ORDER BY T4813.FISCAL_QUARTER_NAME ASC, T13313.GRP ASC, T13596.CRTDDT_DT ASC) as c5
    from
    DW_SF_EMLMSSG_L T13275,
    SF_ORGN_L_DIM T13313,
    CIN_CALENDARS_DIM T4813,
    DW_SF_CS_L T13596 /* SF_CS_L_Fact */
    where ( T4813.CALENDAR_KEY = T13596.CRDT_KEY and T13275.PRNTID = T13596.ID and T13275.STTS = '3' and T13313.ORGN_KEY = T13596.ORGN_KEY and (T4813.FISCAL_YEAR_NAME in ('FY2011', 'FY2012', 'FY2013')) and T4813.FISCAL_QUARTER_NAME <> 'Q1 FY2011' )
    ) D1
    where ( D1.c5 = 1 )
    [2012-10-25T22:20:58.000+00:00] [OracleBIServerComponent] [TRACE:2] [USER-18] [] [ecid: a5bccb33dce3bd12:-c49596b:13a898b42b5:-8000-0000000000007756] [tid: 601c] [requestid: 1d4c0001] [sessionid: 1d4c0000] [username: weblogic] -------------------- Sending query to database named CIN (id: <<178213>>), connection pool named CINADMIN: [[
    select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4,
    D1.c5 as c5,
    D1.c6 as c6,
    D1.c7 as c7
    from
    (select D1.c1 as c1,
    D1.c2 as c2,
    min(D1.c1) over (partition by D1.c6, D1.c7) as c3,
    sum(D1.c2) over (partition by D1.c6, D1.c7) as c4,
    D1.c5 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    ROW_NUMBER() OVER (PARTITION BY D1.c6, D1.c7 ORDER BY D1.c6 ASC, D1.c7 ASC) as c8
    from
    (select min(T13275.MSSGDT_DT) as c1,
    count(T13596.CSNMBR) as c2,
    T4813.FISCAL_YEAR_NAME as c5,
    T4813.FISCAL_QUARTER_NAME as c6,
    T13313.GRP as c7
    from
    DW_SF_EMLMSSG_L T13275,
    SF_ORGN_L_DIM T13313,
    CIN_CALENDARS_DIM T4813,
    DW_SF_CS_L T13596 /* SF_CS_L_Fact */
    where ( T4813.CALENDAR_KEY = T13596.CRDT_KEY and T13275.PRNTID = T13596.ID and T13275.STTS = '3' and T13313.ORGN_KEY = T13596.ORGN_KEY and (T4813.FISCAL_YEAR_NAME in ('FY2011', 'FY2012', 'FY2013')) and T4813.FISCAL_QUARTER_NAME <> 'Q1 FY2011' )
    group by T4813.FISCAL_QUARTER_NAME, T4813.FISCAL_YEAR_NAME, T13313.GRP
    ) D1
    ) D1
    where ( D1.c8 = 1 )

  • Case sensitive statement in the select-statement

    Hi All,
    i have a table in the abap-dictionary filled with names...when i try to select them with the select-statement with condition:
    table-name_column like 'some_name'
    I have encountered some problems...the inquiry is case-sensitive. What i want to do is to read the value from the abap-dictionary table uppercase or lowercase and compare it with the needed value also translated in uppercase or lowercase.
    The only idea i have is to select all values of the dictionary table into an internal table and to translate the values there in uppercase or lowercase and then to loop trough it. But this approach would cost a lot of performance.
    Do someone has an other proposal?

    check...
    Select statement
    It would be difficult , because it is based on how data is stored in the data base , now consider the scenario of the system i am using , we can material description as 'test' or 'TEST' , 'Test' .
    If in your system there are only stored in either caps or small the you can perform the select twice .
    But i myself dont find it to be such a good solution , but you can give it a try
    There is one more solution specific to material description ,and that is in the table MAKT there is a field MAKTG , which stored the description in uppercase , so for this you can first convert the description to uppercase and then perform select on this field

  • OPEN CURSOR using a WITH clause in the select query

    Hi,
    I am using Oracle 9i. I have a requirement where I have a REFCURSOR as an OUT parameter for my procedure. I have declared the TYPE and created the procedure.
    In the procedure, I am using OPEN <cursor_name> FOR <query>;
    Ideally this works in most of the cases that I have tried earlier. However, in the current case I am using a WITH clause in my query to get the results.
    I need help in understanding if the above mentioned syntax would not allow me to use the WITH clause in the query.

    What error do you get , seems to work ok for me on 10g
    SQL> begin
      2  open :cv for 'with x as (select * from emp)  select * from x';
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> print :cv
         EMPNO
    ENAME
    JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7521
    WARD
    SALESMAN        7698 22-FEB-81       1250        500         30
          7566
    JONES
    MANAGER         7839 02-APR-81       2975                    20
         EMPNO

  • Insert using case when

    hello ,
    i wanna use "case when" statement in the insert , i implement it like this :
    currentyear:=1;
    insert into test1 (ATTRIB1,ATTRIB2) values ((case when currentyear=1 then 'ok' else 'notOK' end),'val2' );
    but it didn't work, i got this error :
    ORA-14551: cannot perform a DML operation inside a query
    Regards
    Elyes
    Edited by: user10393090 on 5 janv. 2009 03:32

    Better approach is ->
    insert into test1 (ATTRIB1,ATTRIB2)
    select case
             when &currentyear=1 then
              'ok'
           else
             'notOK'
           end AS attrib1,
           'val2' AS attrib2
    from dual;N.B.: Not Tested...
    Regards.
    Satyaki De.

  • How to create nested case when statement in OBIEE 11g?

    Hi All,
    I need to create a formula using nested case when statement. The formula to be created is below:
    =If([AWRV]<0; "<0";
    If([AWRV]=0; "0";
    If([AWRV]<=15; ">0 and <=15";
    If([AWRV]<=25; ">15 and <=25";
    If([AWRV]<=50; ">25 and <=50";
    If([AWRV]<=75; ">50 and <=75";
    If([AWRV]<=100; ">75 and <=100";
    If([AWRV]<=200; ">100 and <=200";
    If([AWRV]<=500; ">200 and <=500";
    If([AWRV]<=1000; ">500 and <=1000";
    If([AWRV]<=5000; ">1000 and <=5000";
    If([AWRV]<=10000; ">5000 and <=10000"; ">10000"))))))))))))
    How to recreate using Nested case when? I tried in many different ways but it is displaying syntax error in obiee11g. This is very critical. Can anybody shed light on this issue pls?
    Thanks in advance,
    Thenmozhi

    Honey26 wrote:
    Hi All,
    I need to create a formula using nested case when statement. The formula to be created is below:
    =If([AWRV]<0; "<0";
    If([AWRV]=0; "0";
    If([AWRV]<=15; ">0 and <=15";
    If([AWRV]<=25; ">15 and <=25";
    If([AWRV]<=50; ">25 and <=50";
    If([AWRV]<=75; ">50 and <=75";
    If([AWRV]<=100; ">75 and <=100";
    If([AWRV]<=200; ">100 and <=200";
    If([AWRV]<=500; ">200 and <=500";
    If([AWRV]<=1000; ">500 and <=1000";
    If([AWRV]<=5000; ">1000 and <=5000";
    If([AWRV]<=10000; ">5000 and <=10000"; ">10000"))))))))))))
    How to recreate using Nested case when? I tried in many different ways but it is displaying syntax error in obiee11g. This is very critical. Can anybody shed light on this issue pls?
    Thanks in advance,
    ThenmozhiTry the below:
    CASE WHEN "Fact - Open Chargeback"."Sub Chbk Amt" < 0 THEN ' <0'
    WHEN "Fact - Open Chargeback"."Sub Chbk Amt" = 0 THEN '0'
    WHEN "Fact - Open Chargeback"."Sub Chbk Amt" BETWEEN 0 AND 15 THEN '>0 AND <=15'
    END
    Hope this helps.

  • Obiee nested case when statements

    Hi Obiee Experts, I need to retrieve amounts for 'last september' so i created a column using this case statement: case when MONTH(CURRENT_DATE) <= 9 then (YEAR(CURRENT_DATE) -1) * 100 + 9 END  --  now i want to retrieve the amount for last september using another case statemnt but i get a syntax err message, when i use: CASE WHEN (case when MONTH (CURRENT_DATE) <= 9 then (YEAR(CURRENT_DATE) -1) * 100 + 9 END) THEN "Fact123"."Net Obligation Amount" END ---- Any ideas how to resolve? I will be forever grateful - cheers, Elena

    Honey26 wrote:
    Hi All,
    I need to create a formula using nested case when statement. The formula to be created is below:
    =If([AWRV]<0; "<0";
    If([AWRV]=0; "0";
    If([AWRV]<=15; ">0 and <=15";
    If([AWRV]<=25; ">15 and <=25";
    If([AWRV]<=50; ">25 and <=50";
    If([AWRV]<=75; ">50 and <=75";
    If([AWRV]<=100; ">75 and <=100";
    If([AWRV]<=200; ">100 and <=200";
    If([AWRV]<=500; ">200 and <=500";
    If([AWRV]<=1000; ">500 and <=1000";
    If([AWRV]<=5000; ">1000 and <=5000";
    If([AWRV]<=10000; ">5000 and <=10000"; ">10000"))))))))))))
    How to recreate using Nested case when? I tried in many different ways but it is displaying syntax error in obiee11g. This is very critical. Can anybody shed light on this issue pls?
    Thanks in advance,
    ThenmozhiTry the below:
    CASE WHEN "Fact - Open Chargeback"."Sub Chbk Amt" < 0 THEN ' <0'
    WHEN "Fact - Open Chargeback"."Sub Chbk Amt" = 0 THEN '0'
    WHEN "Fact - Open Chargeback"."Sub Chbk Amt" BETWEEN 0 AND 15 THEN '>0 AND <=15'
    END
    Hope this helps.

  • Using more than one case when statement

    Hi there,
    I have a question on using case when statements.
    Currently I have a table where it shows me mulitple dates.
    Order Saledate TransferDate StartDate Enddate GetDate
    I have created a where statement to show me records against the transferdate dependant if it appears within the date range of the year, or if it appears within the startdate and today's date.
    (lpatran.trandate between targets.startdate
    and (case when targets.enddate < getdate() then targets.enddate else getdate() end))
    However on some of the records the transfer date is null, and so they want to use the saledate as the date to use.
    So I created
    (case when Lpatran.trandate is not null then (Lpatran.trandate between targets.startdate
    and (case when targets.enddate < getdate() then targets.enddate else getdate()))
    else (lpatran.saledate between targets.startdate
    and (case when targets.enddate < getdate() then targets.enddate else getdate())) end )
    However it gives me an incorrect syntax near the word ‘between ‘ 
    Is there a simple fix for this or does sql not allow me to do this?

    I have created a new column called transferdate and done a case when statement
    CASE
    WHEN lpatran.trandate
    IS
    NULL
    THEN lpatran.saledate
    ELSE lpatran.trandate
    END
    AS Transferdate,
    Then created a temptable and did a select * from temptable.  Created a where statement from transferdate, which does work and gives me the correct data. 
    TransferDate between startdate
    and(case
    when enddate
    <
    getdate()
    then enddate
    else
    getdate()
    end))
    However I wanted to know if there was a way of obtaining the same data without having to use the temptable ?

  • Update multiple rows using CASE WHEN

    I have the table ACCOUNT of structure as follow: 
    ACCOUNT_ID
    ACCOUNT_STATUS
    004460721
    2
    042056291
    5
    601272065
    3
    I need to update the three rows at once using one SELECT statement such that, the second column will be 5, 3, 2 respectively.
    I used the following query but seems there is something missing
    UPDATE ACCOUNT
    SET ACCOUNT_STATUS = CASE  
    WHEN ACCOUNT_STATUS = '004460721' THEN 5 
    WHEN ACCOUNT_STATUS = '042056291' THEN 3 
    WHEN ACCOUNT_STATUS = '601272065' THEN 2 
    WHERE ACCOUNT_ID IN ('004460721','042056291','601272065') 
    My question, is this way correct? if no, can I use CASE WHEN statement and how or I only have choice of using SUB-SELECT to acheive that in one statement?

    Hi,
    Hawk333 wrote:
    I have the table ACCOUNT of structure as follow:
    ACCOUNT_ID
    ACCOUNT_STATUS
    004460721
    2
    042056291
    5
    601272065
    3
    I need to update the three rows at once using one SELECT statement such that, the second column will be 5, 3, 2 respectively.
    I used the following query but seems there is something missing
    UPDATE ACCOUNT
    SET ACCOUNT_STATUS = CASE  
    WHEN ACCOUNT_STATUS = '004460721' THEN 5 
    WHEN ACCOUNT_STATUS = '042056291' THEN 3 
    WHEN ACCOUNT_STATUS = '601272065' THEN 2 
    WHERE ACCOUNT_ID IN ('004460721','042056291','601272065') 
    My question, is this way correct? if no, can I use CASE WHEN statement and how or I only have choice of using SUB-SELECT to acheive that in one statement?
    What happens when you try it?
    Did you mean "WHEN ACCOUNT_ID = ..."?
    A CASE expressions always needs an END keyword.
    Depending on your requirements (that is, why are those rows being changed, and how do you determine the new values) a CASE expression in an UPDATE statement, similar to what you posted, could be a good way to do it.  MERGE (instead of UPDATE) would also be an option, especially if you want to avoid updating rows that already happen to have the correct values.

  • Doubt in case when statement

    hi gems...
    i have a case when statement in a select clause...there are total three conditions in the case when statemnt.
    now my question is if all theconditions gets matched, then what will happen???
    is only first condition gets executed and rest two will be ignored or the third condition will overwrite the previous two???
    please help...thanks in advance...

    Hello
    This isn't very difficult to test....
    select
         CASE
              WHEN 1=1 THEN
                1
              WHEN 1=1 THEN
                2
              WHEN 1=1 THEN
                3
         END c
    FROM
         dual
             C
             1
    1 row selected.It wil return the first match.
    David

  • CASE WHEN statement

    Hello everybody,
    I have the following SQL statement. To verify that p01.euro IS NOT NULL, I think I should add a "CASE WHEN" statement into the code, the problem is, that I don't know how to this here... The "CASE WHEN" statement should be for the subselect - statement I've marked in red color...
    Perhaps you have an idea... Thanks
    select
    (select apex_item.select_list_from_query (5,name,'select name from cn_pl_projektidee order by idee_id asc', 'style="width:130px"', NULL) name
    from cn_pl_projektidee s01 where s01.idee_id = t1.idee_id) idee,
    (select htmldb_item.text(6,sum(stunden))stunden_ilp from cn_pl_std_peplanung t02
    where abt_id = '1' 
    and  t02.pe_id = t1.pe_id
    and  t02.version_id = t1.version_id
    and  t02.idee_id = t1.idee_id) stunden_ilp,
    (select htmldb_item.text(7,sum(stunden))stunden_ild from cn_pl_std_peplanung t02
    where abt_id = '3' 
    and  t02.pe_id = t1.pe_id
    and  t02.version_id = t1.version_id
    and  t02.idee_id = t1.idee_id) stunden_ild,
    (select htmldb_item.text(8,sum(stunden))stunden_ilm from cn_pl_std_peplanung t02
    where abt_id = '4' 
    and  t02.pe_id = t1.pe_id
    and  t02.version_id = t1.version_id
    and  t02.idee_id = t1.idee_id) stunden_ilm,
    (select htmldb_item.text(9,sum(stunden))stunden_ief from cn_pl_std_peplanung t02
    where abt_id = '9' 
    and  t02.pe_id = t1.pe_id
    and  t02.version_id = t1.version_id
    and  t02.idee_id = t1.idee_id) stunden_ief,
    (select htmldb_item.text(10,sum(stunden))stunden_ir from cn_pl_std_peplanung t02
    where abt_id = '10' 
    and  t02.pe_id = t1.pe_id
    and  t02.version_id = t1.version_id
    and  t02.idee_id = t1.idee_id) stunden_ir,
    (select sum(euro) from cn_pl_primaerkostenplanung p01
    where p01.pe_id = t1.pe_id
    and  p01.version_id = t1.version_id
    and  p01.idee_id = t1.idee_id) summe_la,
    "CASE WHEN p01.euro IS NOT NULL THEN"
    (select sum((sum(t02.stunden) * k01.euro_std * 8)+(select sum(p01.euro) from cn_pl_primaerkostenplanung p01
    where p01.pe_id = t1.pe_id
    and  p01.version_id = t1.version_id
    and  p01.idee_id = t1.idee_id))
    from cn_pl_std_peplanung t02, cn_pl_sap_leistungsarten k01
    where k01.l_art_id = t1.l_art_id
    and t02.pe_id = t1.pe_id
    and  t02.version_id = t1.version_id
    and  t02.idee_id = t1.idee_id
    group by t02.pe_id, k01.euro_std) "END" kosten_ges,
    (select distinct htmldb_item.hidden(2,pe_id) pe_id from cn_pl_std_peplanung t02
    where t02.pe_id = t1.pe_id
    and  t02.version_id = t1.version_id) pe_id,
    (select  distinct htmldb_item.hidden(3,l_art_id) l_art_id from cn_pl_std_peplanung t02
    where t02.pe_id = t1.pe_id
    and  t02.version_id = t1.version_id) l_art_id,
    (select distinct htmldb_item.hidden(4,version_id) version_id from cn_pl_std_peplanung t02
    where t02.pe_id = t1.pe_id
    and  t02.version_id = t1.version_id) version_id
    from cn_pl_std_peplanung t1, cn_pl_projektelemente z1, cn_pl_version u1, cn_pl_projektidee s1
    where t1.version_id = '&P6_VERSION_WAHL.' and t1.pe_id ='&P6_HELP_PRODET.'  and t1.l_art_id ='&P6_L_ART_ID.'
    group by t1.pe_id, t1.version_id, t1.idee_id, t1.l_art_id order by t1.idee_id desc

    Not sure if the rest is ok, but syntactically you can go for
      SELECT (SELECT apex_item.select_list_from_query (
                        5,
                        name,
                        'select name from cn_pl_projektidee order by idee_id asc',
                        'style="width:130px"',
                        NULL
                        name
                FROM cn_pl_projektidee s01
               WHERE s01.idee_id = t1.idee_id)
                idee,
             (SELECT htmldb_item.text (6, SUM (stunden)) stunden_ilp
                FROM cn_pl_std_peplanung t02
               WHERE     abt_id = '1'
                     AND t02.pe_id = t1.pe_id
                     AND t02.version_id = t1.version_id
                     AND t02.idee_id = t1.idee_id)
                stunden_ilp,
             (SELECT htmldb_item.text (7, SUM (stunden)) stunden_ild
                FROM cn_pl_std_peplanung t02
               WHERE     abt_id = '3'
                     AND t02.pe_id = t1.pe_id
                     AND t02.version_id = t1.version_id
                     AND t02.idee_id = t1.idee_id)
                stunden_ild,
             (SELECT htmldb_item.text (8, SUM (stunden)) stunden_ilm
                FROM cn_pl_std_peplanung t02
               WHERE     abt_id = '4'
                     AND t02.pe_id = t1.pe_id
                     AND t02.version_id = t1.version_id
                     AND t02.idee_id = t1.idee_id)
                stunden_ilm,
             (SELECT htmldb_item.text (9, SUM (stunden)) stunden_ief
                FROM cn_pl_std_peplanung t02
               WHERE     abt_id = '9'
                     AND t02.pe_id = t1.pe_id
                     AND t02.version_id = t1.version_id
                     AND t02.idee_id = t1.idee_id)
                stunden_ief,
             (SELECT htmldb_item.text (10, SUM (stunden)) stunden_ir
                FROM cn_pl_std_peplanung t02
               WHERE     abt_id = '10'
                     AND t02.pe_id = t1.pe_id
                     AND t02.version_id = t1.version_id
                     AND t02.idee_id = t1.idee_id)
                stunden_ir,
             (SELECT SUM (euro)
                FROM cn_pl_primaerkostenplanung p01
               WHERE     p01.pe_id = t1.pe_id
                     AND p01.version_id = t1.version_id
                     AND p01.idee_id = t1.idee_id)
                summe_la,
             CASE
                WHEN p01.euro IS NOT NULL
                THEN
                   (  SELECT SUM( (SUM (t02.stunden) * k01.euro_std * 8)
                                 + (SELECT SUM (p01.euro)
                                      FROM cn_pl_primaerkostenplanung p01
                                     WHERE     p01.pe_id = t1.pe_id
                                           AND p01.version_id = t1.version_id
                                           AND p01.idee_id = t1.idee_id))
                        FROM cn_pl_std_peplanung t02, cn_pl_sap_leistungsarten k01
                       WHERE     k01.l_art_id = t1.l_art_id
                             AND t02.pe_id = t1.pe_id
                             AND t02.version_id = t1.version_id
                             AND t02.idee_id = t1.idee_id
                    GROUP BY t02.pe_id, k01.euro_std)
             END
                kosten_ges,
             (SELECT DISTINCT htmldb_item.hidden (2, pe_id) pe_id
                FROM cn_pl_std_peplanung t02
               WHERE t02.pe_id = t1.pe_id AND t02.version_id = t1.version_id)
                pe_id,
             (SELECT DISTINCT htmldb_item.hidden (3, l_art_id) l_art_id
                FROM cn_pl_std_peplanung t02
               WHERE t02.pe_id = t1.pe_id AND t02.version_id = t1.version_id)
                l_art_id,
             (SELECT DISTINCT htmldb_item.hidden (4, version_id) version_id
                FROM cn_pl_std_peplanung t02
               WHERE t02.pe_id = t1.pe_id AND t02.version_id = t1.version_id)
                version_id
        FROM cn_pl_std_peplanung t1,
             cn_pl_projektelemente z1,
             cn_pl_version u1,
             cn_pl_projektidee s1
       WHERE     t1.version_id = '&P6_VERSION_WAHL.'
             AND t1.pe_id = '&P6_HELP_PRODET.'
             AND t1.l_art_id = '&P6_L_ART_ID.'
    GROUP BY t1.pe_id,
             t1.version_id,
             t1.idee_id,
             t1.l_art_id
    ORDER BY t1.idee_id DESC

  • Is Prompted (Case When Statement)

    I created a column in an answers report and used a CASE WHEN statement as the formula. I set this column to an Is Prompted filter. But when i try to run the report from the dashboard prompt, it just ignores this filter. What am i doing wrong?

    Hello,
    Prompt also should contain the same case when condition in it's fx so that.. when you say is prompted on that code in answers, prompt value will be effected in the answers.
    Else assign a presentation variable to the prompt (if it's drop - down controlled), and use that presentation variable in the filter section of your request...
    Hope you get it..

Maybe you are looking for