How to specify an outer join in query builder

I've very quickly built a large query with the query builder, and it works fine, but only produces 9 out of 2200 records - so I need to change it to an outer join.
My problem is that I can't seem to find a way to specify an outer join. I've tried editing the query that query builder formed, but it won't let me.
I know I can capture the query, edit it and run it in sql developer, and that works fine, but I want to use query builder as it is the fastest way I know of to quickly add and remove items - my users are unsure of exactly what to include.
I know it is kind of a trivial question, but i've searched the forum, the manual, the web and no luck
Thanks for any help you can give
Glenn

Hi Glenn,
When you use the Query Builder to create the sql statement, you should click on the empty square to the right of the fields on each table to create the join. When you've done this, you should see a line drawn between the two tables. Click on this line and a small popup appears allowing you to select inner, left outer or right outer joins.
Once the report has been created, though, you need to edit the statement. For example, if you use the Query Builder to join DEPT to EMP based on the DEPTNO field on both tables, you get:
select      "DEPT"."DEPTNO" as "DEPTNO",
      "DEPT"."DNAME" as "DNAME",
      "DEPT"."LOC" as "LOC",
      "EMP"."EMPNO" as "EMPNO",
      "EMP"."ENAME" as "ENAME",
      "EMP"."JOB" as "JOB",
      "EMP"."MGR" as "MGR",
      "EMP"."HIREDATE" as "HIREDATE"
from      "EMP" "EMP",
      "DEPT" "DEPT"
where   "DEPT"."DEPTNO"="EMP"."DEPTNO"Change this to:
select      "DEPT"."DEPTNO" as "DEPTNO",
      "DEPT"."DNAME" as "DNAME",
      "DEPT"."LOC" as "LOC",
      "EMP"."EMPNO" as "EMPNO",
      "EMP"."ENAME" as "ENAME",
      "EMP"."JOB" as "JOB",
      "EMP"."MGR" as "MGR",
      "EMP"."HIREDATE" as "HIREDATE"
from      "EMP" "EMP"
      LEFT OUTER JOIN "DEPT" "DEPT" ON "DEPT"."DEPTNO"="EMP"."DEPTNO"Andy

Similar Messages

  • How to Specify Left Outer Join in OWB

    If I run the query:
    select s.school_id,
    nvl(max(decode(cv.cat_id, 'UCL', cv.long_desc, null)),'Unknown') UCL,
    nvl(max(decode(cv.cat_id, 'REGION', cv.long_desc, null)),'Unknown') REGION,
    nvl(max(decode(cv.cat_id, 'TREASREG', cv.long_desc, null)),'Unknown') TREASREG,
    nvl(max(decode(cv.cat_id, 'RELGN', cv.long_desc, null)),'Unknown') RELGN,
    nvl(max(decode(cv.cat_id, 'NGEFF', cv.long_desc, null)),'Unknown') NGEFF,
    nvl(max(decode(cv.cat_id, 'PCAP', cv.long_desc, null)),'Unknown') PCAP,
    nvl(max(decode(cv.cat_id, 'ATSIC', cv.long_desc, null)),'Unknown') ATSIC
    from sdw.sdr_schools s
    left outer join
    sdw.sdr_school_category_values scv on s.school_id = scv.school_id
    left outer join
    sdw.sdr_category_values cv on cv.cat_id = scv.cat_id
    and cv.cat_value_id = scv.cat_value_id
    group by s.school_id
    order by s.school_id
    I get 1706 records. In OWB I get 1656 records.
    In OWB I use a JOIN for the three tables, then an expression for the decode lines and sort and then the final table. In the SQL above, if the second left outer join is removed I get 1656 records?
    Ho do you force OWB to produce 1706 records?

    You have to use the (+) notation.
    e.g.
    table1.column1 (+) = table2.column1
    Also, you can do a full-outer-join using table1.column1 (+) = table2.column1 (+) even though this is not legal SQL*Plus syntax.

  • How to use left outer joins ,right outer joins and order by clause for belo

    Hi,
    How to use left outer joins ,right outer joins and order by clause for below XML query.
    The query which is red colour returns null then its not displaying any values for columns in that tables. Tried decode, nvl function hasn't worked.
    SELECT XMLAGG ( XMLELEMENT( "P", XMLFOREST( P.process_id AS Ppid,
              (SELECT XMLAGG( XMLELEMENT( "PI", XMLFOREST( PI.question_id AS PIqid,
                                       PI.process_id AS PIpid,
    PI.innertext AS
                                       PItext, PI.itemtype AS PItype,
                                       PI.linkfrom AS PIfrom,
                                       PI.linkto AS PIto,
    PI.associated AS PIas,
                                       PI.content_id AS PIc,
                                       PI.exitpoint1_id AS PIe1,
                                       PI.exitpoint2_id AS PIe2,
                                       PI.exitpoint3_id AS PIe3,
                                       PI.followoncall AS PIfoc,
    PI.userinput AS PIui,
                                       PI.resolveidentifier AS PIri,
    PI.libquestion_idfk AS PIlqid,
                                       PI.isLocked AS PIstls,
                                       PI.PreviousAnswer AS PIPAns,
                                       PI.VisibleToAgent AS PIVAgent,
                                       PI.RetryAttempt AS PIRetry,
                                       PI.Tags AS PITag,
                                  SELECT XMLAGG( XMLELEMENT( "PO", XMLFOREST( PO.option_id AS POoid,
                                       PO.question_id AS POqid,
                                                           PO.process_id AS popid,
                                                           PO.opt_innertext AS POtext,
                                                           PO.opt_linkfrom AS POfrom,
                                                           PO.opt_linkto AS POto,
                                                           PO.libquestion_idfk AS POlqid,
                                                           PO.liboption_idfk AS POloid ) ) )
                                  FROM vw_liveProcessOption_Sim_v6 PO
                                       WHERE PI.question_id = PO.question_id (+)
                                  AND PI.process_id = PO.process_id (+)
                                  ) "A" ) ) ) AS "PO"
         FROM vw_liveProcessItem_Sim_v6 PI
              WHERE P.process_id = PI.process_id
              ) "A" ) ) ) AS "PI"
    FROM liveProcess_ec P
    WHERE (P.process_id = 450)
    Any help really appreciated.
    Thanks

    user512743 wrote:
    Hi,
    Here below is the scripts of tables, insert statements and Required output.
    CREATE TABLE VW_LIVEPROCESSOPTION_SIM_v6
    (     "OPTION_ID" NUMBER,
         "QUESTION_ID" NUMBER(10,0),
         "PROCESS_ID" NUMBER(10,0),
         "OPT_INNERTEXT" VARCHAR2(200 CHAR),
         "OPT_LINKFROM" VARCHAR2(20 CHAR),
         "OPT_LINKTO" VARCHAR2(20 CHAR),
         "LIBQUESTION_IDFK" NUMBER,
         "LIBOPTION_IDFK" NUMBER
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,2,450,'Yes',null,'5',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,3,450,'Yes',null,'5',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,5,450,'Yes',null,'6',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,6,450,'Yes',null,'7',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,8,450,'Block All',null,'9',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,9,450,'Yes',null,'10',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,11,450,'Yes',null,'12',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,12,450,'Yes',null,'13',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,14,450,'Yes',null,'16',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,2,450,'No',null,'3',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,3,450,'No',null,'4',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,5,450,'No',null,'8',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,6,450,'No',null,'8',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,8,450,'Standard',null,'11',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,9,450,'No',null,'11',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,11,450,'No',null,'14',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,12,450,'No',null,'14',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,14,450,'No',null,'15',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (3,8,450,'Disabled',null,'12',null,null);
    Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (4,8,450,'User Defined',null,'12',null,null);
    REATE TABLE "VW_LIVEPROCESSITEM_SIM_v6"
    (     "QUESTION_ID" NUMBER(10,0),
         "PROCESS_ID" NUMBER(10,0),
         "INNERTEXT" VARCHAR2(200 CHAR),
         "ITEMTYPE" VARCHAR2(50 CHAR),
         "LINKFROM" VARCHAR2(500 CHAR),
         "LINKTO" VARCHAR2(500 CHAR),
         "ASSOCIATED" VARCHAR2(200 CHAR),
         "CONTENT_ID" NUMBER,
         "EXITPOINT1_ID" NUMBER(10,0),
         "EXITPOINT2_ID" NUMBER(10,0),
         "EXITPOINT3_ID" NUMBER(10,0),
         "RESOLVEIDENTIFIER" VARCHAR2(40 CHAR),
         "LIBQUESTION_IDFK" NUMBER(10,0),
         "FOLLOWONCALL" NUMBER(1,0),
         "USERINPUT" VARCHAR2(200 CHAR),
         "ISLOCKED" NUMBER(1,0),
         "PREVIOUSANSWER" NUMBER(1,0),
         "VISIBLETOAGENT" NUMBER(1,0),
         "RETRYATTEMPT" NUMBER(10,0),
         "TAGS" VARCHAR2(50 BYTE)
    Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (1,450,'CBB1015 - Router Firewall Settinngs Process','Title',null,'2',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
    Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (2,450,'Is the customers PC Firewall turned off?','Question','1','2.2,2.1',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
    Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (3,450,'Advise the customer to turn off the PC Firewall in order to continue. Has this been done?','Question','2.2','3.2,3.1',null,278,null,null,null,null,null,null,null,null,null,null,null,null);
    Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (4,450,'Advise the customer the PC Firewall must be switched off before this process????','ExitPoint','3.2',null,null,null,14,null,null,null,null,null,null,null,null,null,null,null);
    Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (5,450,'Is the customer able to access the internet now?','Question','3.1,2.1','5.2,5.1',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
    Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (6,450,'Is the customer having a problem with a specific website?','Question','5.1','6.2,6.1',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
    Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (7,450,'1536: CBB1008 - Browser Setup and Daignostics','SubProcess','6.1',null,'1536-1-0',null,null,null,null,null,null,null,null,null,null,null,null,null);
    Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (8,450,'What is the security level on the CPE Management page?','Question','6.2,5.2','8.4,8.3,8.2,8.1',null,279,null,null,null,null,null,null,null,null,null,null,null,null);
    Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (9,450,'Change the security level to Standard. Does this resolve the customers issue?','Question','8.1','9.2,9.1',null,280,null,null,null,null,null,null,null,null,null,null,null,null);
    Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (10,450,'Issue Resolved','ExitPoint','9.1',null,null,null,1,6,122,null,null,null,null,null,null,null,null,null);
    Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (11,450,'Change the security level to Disabled. Is the customer able to browse the internet?','Question','9.2,8.2','11.2,11.1',null,281,null,null,null,null,null,null,null,null,null,null,null,null);
    Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (12,450,'Change the security level to Standard. Is the customer able to browse the internet now?','Question','11.1,8.3,8.4','12.2,12.1',null,283,null,null,null,null,null,null,null,null,null,null,null,null);
    Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (13,450,'Issue Resolved','ExitPoint','12.1',null,null,null,1,6,123,null,null,null,null,null,null,null,null,null);
    Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (14,450,'Ask the customer to perform a master reset. Does this resolve their issue?','Question','12.2,11.2','14.2,14.1',null,282,null,null,null,null,null,null,null,null,null,null,null,null);
    Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (15,450,'Faulty CPE','ExitPoint','14.2',null,null,null,1,6,124,null,null,null,null,null,null,null,null,null);
    Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (16,450,'Issue Resolved','ExitPoint','14.1',null,null,null,1,6,123,null,null,null,null,null,null,null,null,null);
    CREATE TABLE "LIVEPROCESS_EC_V"
    (     "PROCESS_ID" NUMBER(10,0),
         "USER_ID" NUMBER(10,0),
         "CREATED" TIMESTAMP (6)
    Insert into LIVEPROCESS_EC (PROCESS_ID,USER_ID,CREATED) values (450,7460,to_timestamp('21-APR-08 09.34.41.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'));
    Required O/P in XML format
    <P>
    <Ppid>450</Ppid>
    <PI>
    <PIqid>1</PIqid>
    <PIpid>450</PIpid>
    <PItext>CBB1015 - Router Firewall Settinngs Process</PItext>
    <PItype>Title</PItype>
    <PIto>2</PIto>
    <PO />
    </PI>
    <PI>
    <PIqid>2</PIqid>
    <PIpid>450</PIpid>
    <PItext>Is the customers PC Firewall turned off?</PItext>
    <PItype>Question</PItype>
    <PIfrom>1</PIfrom>
    <PIto>2.2,2.1</PIto>
    <PO>
    <POoid>1</POoid>
    <POqid>2</POqid>
    <popid>450</popid>
    <POtext>Yes</POtext>
    <POto>5</POto>
    </PO>
    <PO>
    <POoid>2</POoid>
    <POqid>2</POqid>
    <popid>450</popid>
    <POtext>No</POtext>
    <POto>3</POto>
    </PO>
    </PI>
    <PI>
    <PIqid>3</PIqid>
    <PIpid>450</PIpid>
    <PItext>Advise the customer to turn off the PC Firewall in order to continue. Has this been done?</PItext>
    <PItype>Question</PItype>
    <PIfrom>2.2</PIfrom>
    <PIto>3.2,3.1</PIto>
    <PIc>278</PIc>
    <PO>
    <POoid>1</POoid>
    <POqid>3</POqid>
    <popid>450</popid>
    <POtext>Yes</POtext>
    <POto>5</POto>
    </PO>
    <PO>
    <POoid>2</POoid>
    <POqid>3</POqid>
    <popid>450</popid>
    <POtext>No</POtext>
    <POto>4</POto>
    </PO>
    </PI>
    <PI>
    <PIqid>4</PIqid>
    <PIpid>450</PIpid>
    <PItext>Advise the customer the PC Firewall must be switched off before this process????</PItext>
    <PItype>ExitPoint</PItype>
    <PIfrom>3.2</PIfrom>
    <PIe1>14</PIe1>
    <PO />
    </PI>
    <PI>
    <PIqid>5</PIqid>
    <PIpid>450</PIpid>
    <PItext>Is the customer able to access the internet now?</PItext>
    <PItype>Question</PItype>
    <PIfrom>3.1,2.1</PIfrom>
    <PIto>5.2,5.1</PIto>
    <PO>
    <POoid>1</POoid>
    <POqid>5</POqid>
    <popid>450</popid>
    <POtext>Yes</POtext>
    <POto>6</POto>
    </PO>
    <PO>
    <POoid>2</POoid>
    <POqid>5</POqid>
    <popid>450</popid>
    <POtext>No</POtext>
    <POto>8</POto>
    </PO>
    </PI>
    <PI>
    <PIqid>6</PIqid>
    <PIpid>450</PIpid>
    <PItext>Is the customer having a problem with a specific website?</PItext>
    <PItype>Question</PItype>
    <PIfrom>5.1</PIfrom>
    <PIto>6.2,6.1</PIto>
    <PO>
    <POoid>1</POoid>
    <POqid>6</POqid>
    <popid>450</popid>
    <POtext>Yes</POtext>
    <POto>7</POto>
    </PO>
    <PO>
    <POoid>2</POoid>
    <POqid>6</POqid>
    <popid>450</popid>
    <POtext>No</POtext>
    <POto>8</POto>
    </PO>
    </PI>
    <PI>
    <PIqid>7</PIqid>
    <PIpid>450</PIpid>
    <PItext>1536: CBB1008 - Browser Setup and Daignostics</PItext>
    <PItype>SubProcess</PItype>
    <PIfrom>6.1</PIfrom>
    <PIas>1536-1-0</PIas>
    <PO />
    </PI>
    <PI>
    <PIqid>8</PIqid>
    <PIpid>450</PIpid>
    <PItext>What is the security level on the CPE Management page?</PItext>
    <PItype>Question</PItype>
    <PIfrom>6.2,5.2</PIfrom>
    <PIto>8.4,8.3,8.2,8.1</PIto>
    <PIc>279</PIc>
    <PO>
    <POoid>1</POoid>
    <POqid>8</POqid>
    <popid>450</popid>
    <POtext>Block All</POtext>
    <POto>9</POto>
    </PO>
    <PO>
    <POoid>2</POoid>
    <POqid>8</POqid>
    <popid>450</popid>
    <POtext>Standard</POtext>
    <POto>11</POto>
    </PO>
    <PO>
    <POoid>3</POoid>
    <POqid>8</POqid>
    <popid>450</popid>
    <POtext>Disabled</POtext>
    <POto>12</POto>
    </PO>
    <PO>
    <POoid>4</POoid>
    <POqid>8</POqid>
    <popid>450</popid>
    <POtext>User Defined</POtext>
    <POto>12</POto>
    </PO>
    </PI>
    <PI>
    <PIqid>9</PIqid>
    <PIpid>450</PIpid>
    <PItext>Change the security level to Standard. Does this resolve the customers issue?</PItext>
    <PItype>Question</PItype>
    <PIfrom>8.1</PIfrom>
    <PIto>9.2,9.1</PIto>
    <PIc>280</PIc>
    <PO>
    <POoid>1</POoid>
    <POqid>9</POqid>
    <popid>450</popid>
    <POtext>Yes</POtext>
    <POto>10</POto>
    </PO>
    <PO>
    <POoid>2</POoid>
    <POqid>9</POqid>
    <popid>450</popid>
    <POtext>No</POtext>
    <POto>11</POto>
    </PO>
    </PI>
    <PI>
    <PIqid>10</PIqid>
    <PIpid>450</PIpid>
    <PItext>Issue Resolved</PItext>
    <PItype>ExitPoint</PItype>
    <PIfrom>9.1</PIfrom>
    <PIe1>1</PIe1>
    <PIe2>6</PIe2>
    <PIe3>122</PIe3>
    <PO />
    </PI>
    <PI>
    <PIqid>11</PIqid>
    <PIpid>450</PIpid>
    <PItext>Change the security level to Disabled. Is the customer able to browse the internet?</PItext>
    <PItype>Question</PItype>
    <PIfrom>9.2,8.2</PIfrom>
    <PIto>11.2,11.1</PIto>
    <PIc>281</PIc>
    <PO>
    <POoid>1</POoid>
    <POqid>11</POqid>
    <popid>450</popid>
    <POtext>Yes</POtext>
    <POto>12</POto>
    </PO>
    <PO>
    <POoid>2</POoid>
    <POqid>11</POqid>
    <popid>450</popid>
    <POtext>No</POtext>
    <POto>14</POto>
    </PO>
    </PI>
    <PI>
    <PIqid>12</PIqid>
    <PIpid>450</PIpid>
    <PItext>Change the security level to Standard. Is the customer able to browse the internet now?</PItext>
    <PItype>Question</PItype>
    <PIfrom>11.1,8.3,8.4</PIfrom>
    <PIto>12.2,12.1</PIto>
    <PIc>283</PIc>
    <PO>
    <POoid>1</POoid>
    <POqid>12</POqid>
    <popid>450</popid>
    <POtext>Yes</POtext>
    <POto>13</POto>
    </PO>
    <PO>
    <POoid>2</POoid>
    <POqid>12</POqid>
    <popid>450</popid>
    <POtext>No</POtext>
    <POto>14</POto>
    </PO>
    </PI>
    <PI>
    <PIqid>13</PIqid>
    <PIpid>450</PIpid>
    <PItext>Issue Resolved</PItext>
    <PItype>ExitPoint</PItype>
    <PIfrom>12.1</PIfrom>
    <PIe1>1</PIe1>
    <PIe2>6</PIe2>
    <PIe3>123</PIe3>
    <PO />
    </PI>
    <PI>
    <PIqid>14</PIqid>
    <PIpid>450</PIpid>
    <PItext>Ask the customer to perform a master reset. Does this resolve their issue?</PItext>
    <PItype>Question</PItype>
    <PIfrom>12.2,11.2</PIfrom>
    <PIto>14.2,14.1</PIto>
    <PIc>282</PIc>
    <PO>
    <POoid>1</POoid>
    <POqid>14</POqid>
    <popid>450</popid>
    <POtext>Yes</POtext>
    <POto>16</POto>
    </PO>
    <PO>
    <POoid>2</POoid>
    <POqid>14</POqid>
    <popid>450</popid>
    <POtext>No</POtext>
    <POto>15</POto>
    </PO>
    </PI>
    <PI>
    <PIqid>15</PIqid>
    <PIpid>450</PIpid>
    <PItext>Faulty CPE</PItext>
    <PItype>ExitPoint</PItype>
    <PIfrom>14.2</PIfrom>
    <PIe1>1</PIe1>
    <PIe2>6</PIe2>
    <PIe3>124</PIe3>
    <PO />
    </PI>
    <PI>
    <PIqid>16</PIqid>
    <PIpid>450</PIpid>
    <PItext>Issue Resolved</PItext>
    <PItype>ExitPoint</PItype>
    <PIfrom>14.1</PIfrom>
    <PIe1>1</PIe1>
    <PIe2>6</PIe2>
    <PIe3>123</PIe3>
    <PO />
    </PI>
    </P>
    Thanks in advance
    Edited by: user512743 on Nov 18, 2008 4:46 AM

  • How to tack print out use with Query ?

    Hi
    I have to tack purchase order print out (print details- PO date, BP code, name, item name, Quantity and Amount . System Print Layout means from Purchase Order layout designer) use with Query
    How to tack print out use with Query (system print layout means from  Purchase Order layout designer) ?
    Regards
    Aravind M

    Hi
    I have to take purchase order print out and I created 3 templates for that purchase order in layout designer (Because as per the MIS requirement I created 3 templates, its cover more information). I have to take print out 3 templates at a time. So i try to take print use with Query.
    Regards
    Aravind M

  • How do we find out who the query originator is on the DB2 database side?

    OBIEE 11g will typically connect to the database using a generic account. Some of the queries are using too
    many resources on our DB2 database. How do we find out who the query originator is (by userID), on the DB2 database side, and not on the OBIEE side? Our research is leading us to Query banding used in Teradata.
    We are looking for something similar, that would work in DB2. 

    If you go to www.speedtest.net it will display which ISP you're with in the bottom corner. There are a few other websites which tell you too but the URLs escape me at the minute
    Dean
    BTCare Community Mod
    If you like a post, or want to say thanks for a helpful answer, please click on the Ratings star on the left-hand side of the post.
    If someone answers your question correctly please let other members know by clicking on ’Mark as Accepted Solution’.

  • How to do outer join select query for an APEX report

    Hello everyone,
    I am Ann.
    I have one select statement that calculate the statistics for one month(October 2012 in this example)
    select ph.phase_number
    , sum ( (case
    WHEN ph.date_finished IS NULL OR ph.date_finished > last_day(TO_DATE('Oct 2012','MON YYYY'))
    THEN last_day(TO_DATE('Oct 2012','MON YYYY'))
    ELSE ph.date_finished
    END )
    - ph.date_started + 1) / count(def.def_id) as avg_days
    from phase_membership ph
    inner join court_engagement ce on ph.mpm_eng_id = ce.engagement_id
    inner join defendant def on ce.defendant_id = def.def_id
    where def.active = 1
    and ph.date_started <= last_day(TO_DATE('Oct 2012','MON YYYY'))
    and ph.active = 1
    and UPPER(ce.court_name) LIKE '%'
    group by rollup(phase_number)
    Result is as below
    Phase_Number     AVG_DAYS
    Phase One     8.6666666666666667
    Phase Two     14.6
    Phase Three     12
         11.4615365
    I have other select list mainly list the months between two date value.
    select to_char(which_month, 'MON YYYY') as display_month
    from (
    select add_months(to_date('Aug 2012','MON YYYY'), rownum-1) which_month
    from all_objects
    where
    rownum <= months_between(to_date('Oct 2012','MON YYYY'), add_months(to_date('Aug 2012','MON YYYY'), -1))
    order by which_month )
    Query result is as below
    DISPLAY_MONTH
    AUG 2012
    SEP 2012
    OCT 2012
    Is there any way that I can join these two select statement above to generate a result like:
    Month          Phase Number     Avg days
    Aug 2012     Phase One     8.666
    Sep 2012     Phase One     7.66
    Oct 2012     Phase One     5.66
    Aug 2012     Phase Two     8.666
    Sep 2012     Phase Two     7.66
    Oct 2012     Phase Two     5.66
    Aug 2012     Phase Three     8.666
    Sep 2012     Phase Three     7.66
    Oct 2012     Phase Three     5.66
    Or
    Month          Phase Number     Avg days
    Aug 2012     Phase One     8.666
    Aug 2012     Phase Two     7.66
    Aug 2012     Phase Three     5.66
    Sep 2012     Phase One     8.666
    Sep 2012     Phase Two     7.66
    Sep 2012     Phase Three     5.66
    Oct 2012     Phase One     8.666
    Oct 2012     Phase Two     7.66
    Oct 2012     Phase Three     5.66
    And it can be order by either Phase Number or Month.
    My other colleague suggest I should use an left outer join but after trying so many ways, I am still stuck.
    One of the select I tried is
    select a.display_month,b.* from (
    select to_char(which_month, 'MON YYYY') as display_month
    from (
    select add_months(to_date('Aug 2012','MON YYYY'), rownum-1) which_month
    from all_objects
    where
    rownum <= months_between(to_date('Oct 2012','MON YYYY'), add_months(to_date('Aug 2012','MON YYYY'), -1))
    order by which_month )) a left outer join
    ( select to_char(ph.date_finished,'MON YYYY') as join_month, ph.phase_number
    , sum ( (case
    WHEN ph.date_finished IS NULL OR ph.date_finished > last_day(TO_DATE(a.display_month,'MON YYYY'))
    THEN last_day(TO_DATE(a.display_month,'MON YYYY'))
    ELSE ph.date_finished
    END )
    - ph.date_started + 1) / count(def.def_id) as avg_days
    from phase_membership ph
    inner join court_engagement ce on ph.mpm_eng_id = ce.engagement_id
    inner join defendant def on ce.defendant_id = def.def_id
    where def.active = 1
    and ph.date_started <= last_day(TO_DATE(a.display_month,'MON YYYY'))
    and ph.active = 1
    and UPPER(ce.court_name) LIKE '%'
    group by to_char(ph.date_finished,'MON YYYY') , rollup(phase_number)) b
    on a.display_month = b.join_month
    but then I get an error
    SQL Error: ORA-00904: "A"."DISPLAY_MONTH": invalid identifier
    I need to display a report on APEX with option for people to download at least CSV format.
    I already have 1 inteactive report in the page, so don’t think can add another interactive report without using the iframe trick.
    If any of you have any ideas, please help.
    Thanks a lot.
    Ann

    First of all, a huge thanks for following this Frank.
    I have just started working here, I think the Oracle version is 11g, but not sure.
    To run Oracle APEX version 4, I think they must have at least 10g R2.
    This report is a bit challenging for me.I has never worked with PARTITION before.
    About the select query you suggested, I run , and it seems working fine, but if I try this,
    it return error ORA-01843: not a valid month
    DEFINE startmonth = "Aug 2012";
    DEFINE endmonth   = "Oct 2012";
    WITH     all_months     AS
         select add_months(to_date('&startmonth','MON YYYY'), rownum-1) AS which_month
         ,      add_months(to_date('&startmonth','MON YYYY'), rownum  ) AS next_month
         from all_objects
         where
         rownum <= months_between(to_date('&endmonth','MON YYYY'), add_months(to_date('&startmonth','MON YYYY'), -1))
    select TO_CHAR (am.which_month, 'Mon YYYY')     AS month
    ,      ph.phase_number
    , sum ( (case
    WHEN ph.date_finished IS NULL OR ph.date_finished > last_day(TO_DATE(am.which_month,'MON YYYY'))
    THEN last_day(TO_DATE(am.which_month,'MON YYYY'))
    ELSE ph.date_finished
    END )
    - ph.date_started + 1) / count(def.def_id) as avg_days
    FROM           all_months          am
    LEFT OUTER JOIN  phase_membership  ph  PARTITION BY (ph.phase_number)
                                        ON  am.which_month <= ph.date_started
                               AND am.next_month  >  ph.date_started
                               AND ph.date_started <= last_day(TO_DATE(am.which_month,'MON YYYY'))  -- May not be needed
                               AND ph.active = 1
    LEFT OUTER join  court_engagement  ce  on  ph.mpm_eng_id = ce.engagement_id
                                        and ce.court_name IS NOT NULL  -- or something involving LIKE
    LEFT OUTER join  defendant         def on  ce.defendant_id = def.def_id
                                        AND def.active = 1
    group by rollup(phase_number, am.which_month)
    ORDER BY  am.which_month
    ,            ph.phase_number
    ;Here is the shorted versions of the three tables:
    A_DEFENDANT, A_ENGAGEMENT, A_PHASE_MEMBERSHIP
    CREATE TABLE "A_DEFENDANT"
        "DEF_ID"     NUMBER NOT NULL ENABLE,
        "FIRST_NAME" VARCHAR2(50 BYTE),
        "SURNAME"    VARCHAR2(20 BYTE) NOT NULL ENABLE,
        "DOB" DATE NOT NULL ENABLE,
        "ACTIVE" NUMBER(2,0) DEFAULT 1 NOT NULL ENABLE,
        CONSTRAINT "A_DEFENDANT_PK" PRIMARY KEY ("DEF_ID"))
    Sample Data
    Insert into A_DEFENDANT (DEF_ID,FIRST_NAME,SURNAME,DOB,ACTIVE) values (101,'Joe','Bloggs',to_date('12/12/99','DD/MM/RR'),1);
    Insert into A_DEFENDANT (DEF_ID,FIRST_NAME,SURNAME,DOB,ACTIVE) values (102,'John','Smith',to_date('20/05/00','DD/MM/RR'),1);
    Insert into A_DEFENDANT (DEF_ID,FIRST_NAME,SURNAME,DOB,ACTIVE) values (103,'Jane','Black',to_date('15/02/98','DD/MM/RR'),1);
    Insert into A_DEFENDANT (DEF_ID,FIRST_NAME,SURNAME,DOB,ACTIVE) values (104,'Minnie','Mouse',to_date('13/12/88','DD/MM/RR'),0);
    Insert into A_DEFENDANT (DEF_ID,FIRST_NAME,SURNAME,DOB,ACTIVE) values (105,'Daisy','Duck',to_date('05/08/00','DD/MM/RR'),1);
    CREATE TABLE "A_ENGAGEMENT"
        "ENGAGEMENT_ID" NUMBER NOT NULL ENABLE,
        "COURT_NAME"    VARCHAR2(50 BYTE) NOT NULL ENABLE,
        "DATE_REFERRED" DATE,
        "DETERMINATION_HEARING_DATE" DATE,
        "DATE_JOINED_COURT" DATE,
        "DATE_TREATMENT_STARTED" DATE,
        "DATE_TERMINATED" DATE,
        "TERMINATION_TYPE" VARCHAR2(50 BYTE),
        "ACTIVE"           NUMBER(2,0) DEFAULT 1 NOT NULL ENABLE,
        "DEFENDANT_ID"     NUMBER,
        CONSTRAINT "A_ENGAGEMENT_PK" PRIMARY KEY ("ENGAGEMENT_ID"))
    Insert into A_ENGAGEMENT (ENGAGEMENT_ID,COURT_NAME,DATE_REFERRED,DETERMINATION_HEARING_DATE,DATE_JOINED_COURT,DATE_TREATMENT_STARTED,DATE_TERMINATED,TERMINATION_TYPE,ACTIVE,DEFENDANT_ID) values (1,'AA',to_date('12/08/12','DD/MM/RR'),null,to_date('12/08/12','DD/MM/RR'),null,null,null,1,101);
    Insert into A_ENGAGEMENT (ENGAGEMENT_ID,COURT_NAME,DATE_REFERRED,DETERMINATION_HEARING_DATE,DATE_JOINED_COURT,DATE_TREATMENT_STARTED,DATE_TERMINATED,TERMINATION_TYPE,ACTIVE,DEFENDANT_ID) values (2,'BB',to_date('01/09/12','DD/MM/RR'),null,to_date('02/09/12','DD/MM/RR'),null,null,null,1,102);
    Insert into A_ENGAGEMENT (ENGAGEMENT_ID,COURT_NAME,DATE_REFERRED,DETERMINATION_HEARING_DATE,DATE_JOINED_COURT,DATE_TREATMENT_STARTED,DATE_TERMINATED,TERMINATION_TYPE,ACTIVE,DEFENDANT_ID) values (3,'AA',to_date('02/09/12','DD/MM/RR'),null,to_date('15/09/12','DD/MM/RR'),null,null,null,1,103);
    Insert into A_ENGAGEMENT (ENGAGEMENT_ID,COURT_NAME,DATE_REFERRED,DETERMINATION_HEARING_DATE,DATE_JOINED_COURT,DATE_TREATMENT_STARTED,DATE_TERMINATED,TERMINATION_TYPE,ACTIVE,DEFENDANT_ID) values (4,'BB',to_date('01/10/12','DD/MM/RR'),null,to_date('02/10/12','DD/MM/RR'),null,null,null,1,105);
    CREATE TABLE "A_PHASE_MEMBERSHIP"
        "MPM_ID"       NUMBER NOT NULL ENABLE,
        "MPM_ENG_ID"   NUMBER NOT NULL ENABLE,
        "PHASE_NUMBER" VARCHAR2(50 BYTE),
        "DATE_STARTED" DATE NOT NULL ENABLE,
        "DATE_FINISHED" DATE,
        "NOTES"  VARCHAR2(2000 BYTE),
        "ACTIVE" NUMBER(2,0) DEFAULT 1 NOT NULL ENABLE,
        CONSTRAINT "A_PHASE_MEMBERSHIP_PK" PRIMARY KEY ("MPM_ID"))
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (1,1,'PHASE ONE',to_date('15/09/12','DD/MM/RR'),to_date('20/09/12','DD/MM/RR'),null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (2,1,'PHASE TWO',to_date('21/09/12','DD/MM/RR'),to_date('29/09/12','DD/MM/RR'),null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (3,2,'PHASE ONE',to_date('12/09/12','DD/MM/RR'),null,null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (4,3,'PHASE ONE',to_date('20/09/12','DD/MM/RR'),to_date('01/10/12','DD/MM/RR'),null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (5,3,'PHASE TWO',to_date('02/10/12','DD/MM/RR'),to_date('15/10/12','DD/MM/RR'),null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (6,4,'PHASE ONE',to_date('03/10/12','DD/MM/RR'),to_date('10/10/12','DD/MM/RR'),null,1);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (7,3,'PHASE THREE',to_date('17/10/12','DD/MM/RR'),null,null,0);
    Insert into A_PHASE_MEMBERSHIP (MPM_ID,MPM_ENG_ID,PHASE_NUMBER,DATE_STARTED,DATE_FINISHED,NOTES,ACTIVE) values (8,1,'PHASE THREE',to_date('30/09/12','DD/MM/RR'),to_date('16/10/12','DD/MM/RR'),null,1);
    The requirements are:
    The user must be able to request the extract for one or more calendar months, e.g.
    May 2013
    May 2013 – Sep 2013.
    The file must contain a separate row for each calendar month in the requested range. Each row must contain the statistics computed for that calendar month.
    The file must also include a row of totals.
    The user must be able to request the extract for either Waitakere or Auckland or Consolidated (both courts’ statistics accumulated).
    Then the part that I am stuck is
    For each monitoring phase:
    Phase name (e.g. “Phase One”)
    Avg_time_in_phase_all_particip
    for each phase name,
    Add up days in each “phase name” Monitoring Phase, calculated as:
    If Monitoring Phase.Date Finished is NULL or > month end date,
    +(*Month end date* Minus Monitoring Phase.Date Started Plus 1)+
    Otherwise (phase is complete)
    +(Monitoring Phase.Date Finished Minus Monitoring Phase.Date Started Plus 1.)+
    Divide by the numbers of all participants who have engaged in “phase name”.
    This is the words of the Business Analyst,
    I try to do as required but still struggle to identify end_month for the above formula to display for the range of months.
    Of course, I can write two nested cursor. The first one run the list of month, then for each month, run the parameterised report.
    But I prefer if possible just use SQL statements, or at least a PL/SQL but return a query.
    With this way, I can create an APEX report, and use their CSV Extract function.
    Yes, you are right, court_name is one of the selection parameters.
    And the statistics is not exactly for one month. It is kind of trying to identify all phases that are running through the specified month (even phase.date_started is before the month start).
    This is the reason why I put the condition AND ph.date_started <= last_day(TO_DATE('Oct 2012','MON YYYY')) (otherwise I get negative avg_days)
    User can choose either one court "AA" or "BB" or combined which is all figures.
    Sorry for bombarding you a lot of information.
    Thanks a lot, again.
    Edited by: Ann586341 on Oct 29, 2012 9:57 PM
    Edited by: Ann586341 on Oct 29, 2012 9:59 PM

  • How to do left outer join in one-one mapping

    I tried to do a left outer join between two tables. I specified
    kodo.jdbc.DBDictionary: JoinSyntax=sql92 in kodo.properties. I used
    ref-join-type="outer" in the package.mapping. However, I still see Kodo is
    translating my queries using inner join. How can I force kodo to use outer
    join (or maybe even to use left outer join) when translating my queries?
    Thanks.

    Kodo will automatically use an outer join when eager-fetching a to-one
    relation (unless you have set null-value="exception" on the field, in
    which case Kodo knows it can use an inner join). There is no need to set
    the ref-join type (in fact, that is only for when the foreign key
    columns are in a joined table).
    When you place criteria on a relation in a query, though, the relation
    must exist to satisfy the query. For example, in the filter:
    "relation.x == y"
    The "relation" field must hold a related object to satisfy the
    expression, just as in Java.
    If you want the "relation" field to optionally be null, then write your
    filter exactly as you would in Java:
    "relation == null || relation.x == y"
    Kodo will correctly use an outer join in this case because the filter
    can be satisfied even when no related object exists.

  • Need to specify LEFT OUTER JOIN while using data from logical database BRM?

    I'm trying to extract data for external processing using SQVI. The fields required are in tables BKPF (Document Header) and BSEG (document detail) so I'm using logical database BRM. Note: required fields include the SPGR* (blocking reasons) which don't appear to be in BSIS/BSAS/BSID/BSAD/BSIK/BSAK, hence I can't just use a Table Join on any of these but have to use BSEG, hence BRM.
    If the document type is an invoice, I also need to include the PO number from table EKKO (PO header), if present, hence I'd like to add this to the list. However, if I do this, it seems that some records are no longer display, e.g. AB documents.
    The interesting thing is that not all records are suppressed, so it's not a simple case of the logical database using an effective INNER JOIN, but the effect is similar.
    In any event, is there a way to specify that the link to table EKKO should be treated as an effective LEFT OUTER JOIN, i.e. records from BKPF/BSEG should be included irrespective of whether any records from EKKO/EKPO exist or not?
    Alternatively, is there some other way to get the SPGR* fields (for example) from BSEG and still join the BKPF? Of course, one solution is to use multiple queries, but I was hoping to avoid this.

    Thanks for everyone's responses, I know how to work around the problem with sql, I am wanting to see if there is a way to make the outer joins filter go in the join clause instead of the where clause with Crystal Reports standard functionality. 
    We have some Crystal Reports users that are not sql users, i.e. benefit specialists, payroll specialists and compensation analysts who have Crystal Reports.  I was hoping this functionality was available for them.  I just made my example a simple one, but often reports have multiple outer joins with maybe 2 or three of the outer joins needing a filter on them that won't make them into an inner join. 
    Such as
    Select person information
    outer join address record
    outer join email record
    outer join tax record (filter for active state record & filter for code = STATE )
    outer join pay rates record
    outer join phone#s  (filter for home phone#)
    I thought maybe the functionality may be available, that I just don't know how or where to use it.  Maybe it is just not available.
    If it is not available, I will probably need to setup some standard views for them to query, rather than expecting them to pull the tables together themselves.

  • How to write an outer join

    Hi,
    Let's suppose I have to write an outer join like this:
    select ...
    from table_1 a, table_2 b
    where a.field1 = b.field1
    and a.field2 >= b.field2
    but I know that for some values there might not to be a matching between the two tables.
    Should I rewtire a query as follows?
    select ...
    from table_1 a, table_2 b
    where a.field1 *(+) =* b.field1
    and a.field2 *(+) >=* b.field2
    I mean, should I put the (+) in both of matches?
    Thanks!

    Please consider the following when you post a question.
    1. New features keep coming in every oracle version so please provide your Oracle DB Version to get the best possible answer.
    You can use the following query and do a copy past of the output.
    select * from v$version 2. We dont know your DB structure or How your Data is. So you need to let us know. The best way would be to give some sample data like this.
    I have the following table called sales
    with sales
    as
          select 1 sales_id, 1 prod_id, 1001 inv_num, 120 qty from dual
          union all
          select 2 sales_id, 1 prod_id, 1002 inv_num, 25 qty from dual
    select *
      from sales 3. Rather than telling what you want in words its more easier when you give your expected output.
    For example in the above sales table, I want to know the total quantity and number of invoice for each product.
    The output should look like this
    Prod_id   sum_qty   count_inv
    1         145       2 4. When ever you get an error message post the entire error message. With the Error Number, The message and the Line number.
    5. Next thing is a very important thing to remember. Please post only well formatted code. Unformatted code is very hard to read.
    Your code format gets lost when you post it in the Oracle Forum. So in order to preserve it you need to
    use the {noformat}{noformat} tags.
    The usage of the tag is like this.
    <place your code here>\
    6. If you are posting a performance related question. Please read
       {thread:id=501834} and {thread:id=863295}.
       Following those guide will be very helpful.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to achieve an outer join with existsNode() function

    I have a requirement to do an outer join with existsNode() function in my where clause. At present my where clause for join is like below
    WHERE A.SOME_ID= “XYZ”
    AND existsNode (B.SOMEXML_FEILD , …. ) = 1
    AND existsNode (C.SOMEOTHERXML_FEILD , …. ) = 1
    In this case if the existsNode fails on B or C, I still want data from A to be selected. How to rewrite this query to achieve that? I kinda want to achieve an outer join

    Hi,
    is this what you are looking for:
    SQL> with t as(select 1 id1,'A' name from dual union all
      2            select 2 ,'B' name from dual union all
      3            select 3,'C' from dual)
      4      ,x as(select 1 id2,xmltype('<a>a</a>') xcol from dual union all
      5            select 2 ,xmltype('<b>b</b>') xcol from dual)
      6  select *
      7  from t,x
      8  where t.id1=x.id2(+)
      9    and (existsNode(x.xcol,'/a')=1 or x.xcol is null);
           ID1 N        ID2 XCOL                                                   
             1 A          1 <a>a</a>                                               
             3 C                                                                   
    SQL> spool off;

  • How do I use OUTER JOIN to email different message than the default

    I have a devotional that goes out daily from a MOBILE table containing:
    mob_id
    calendardate
    title
    scripture
    body
    The same devotional goes out to 3 different churches.
    I have a second TABLE called EDITED that holds an edited version of the daily devotional, containing:
    edit_id
    calendardate
    etitle
    escripture
    ebody
    The query should look in the edited table for a devotional first to see if it matches the current date then send it out. Otherwise it sends out the default devotional  that corresponds with the current date.
    I would like to send out in replacement of the default devotional  to the church that edited the devotional.
    I am using the following outer Join but it doesn’t work. It sends the same devotional to everybody.
    <cfoutput>
    <cfloop query="getClients">
    <!--- determine if there is an edited version of the devotional available for this day --->
    <cfquery name="getDevotional" datasource="#application.dsn#">
    SELECT mobile.mob_id, mobile.display_date, mobile.title, mobile.body, mobile.scripture,edited.edit_id,edited.contact_id,edited.etitle,edited.escripture,edited. ebody
    FROM mobile
    left outer join edited ON mobile.display_date = edited.display_date
    where mobile.display_date = <cfqueryparam value ="#dateformat(now(), "YYYY-MM-DD")#" cfsqltype="cf_sql_date">
    </cfquery>
    What am I missing?

    Yes the getClients grabs all information pertaining to the client and their layout information.
    <cfquery name="getClients" datasource="#application.dsn#">
    select *
    from (subscriber INNER JOIN contacts ON subscriber.contact_id = contacts.contact_id)INNER JOIN layout ON contacts.contact_id = layout.contact_id
    where subscriber.timezone = 3
    </cfquery>
    Below is the logic I used to determine which version to use:
    <cfif getDevotional.edit_id NEQ "">#GetDevotional.etitle#<cfelse>#GetDevotional.title#</cfif>

  • How can define an outer join in the where clause of a flowr statement?

    Hi- In the sample below I'm joining two views based on username but in this case what I really want to use is an outer join instead. What is the syntax for that? I tried the (+) notation but that didn't seem to work..
    CREATE OR REPLACE PROCEDURE proc_ctsi_all is
    XMLdoc XMLType;
    BEGIN
    DBMS_XDB.deleteResource('/public/CTSI/ctsi_all_rpt1.xml',1);
    SELECT XMLQuery(
    '<Progress_Report>
    <Personnel_Roster>
    {for $c in ora:view("CTSI_INVEST_NONPHS_SOURCE_V"),
    $cphs in ora:view("CTSI_INVEST_PHS_SOURCE_V")
      let $username  := $c/ROW/COMMONS_USERNAME/text(),
    $expertise  := $c/ROW/AREA_OF_EXPERTISE/text(),
    $phsorg  := $cphs/ROW/PHS_ORGANIZATION/text(),
    $activitycode  := $cphs/ROW/ACTIVITY_CODE/text(),
    $username2  := $cphs/ROW/COMMONS_USERNAME/text()
    where $username eq $username2
         return
      <Investigator>
       <Commons_Username>{$username}</Commons_Username>
    <Area_of_Expertise>{$expertise}</Area_of_Expertise>
    <Federal_PHS_Funding>
    <Organization>{$phsorg}</Organization>
    <Activity_Code>{$activitycode}</Activity_Code>
    <Six_Digit_Grant_Number>{$grantnumber}</Six_Digit_Grant_Number>
    </Federal_PHS_Funding>
    </Investigator>}
    </Personnel_Roster>
    </Progress_Report>'
    RETURNING CONTENT) INTO XMLdoc FROM DUAL;
    IF(DBMS_XDB.CREATERESOURCE('/public/CTSI/ctsi_all_rpt1.xml', XMLdoc)) THEN
    DBMS_OUTPUT.PUT_LINE('Resource is created');
    ELSE
    DBMS_OUTPUT.PUT_LINE('Cannot create resource');
    END IF;
    COMMIT;
    END;
    /

    What you could do is use query within an XMLTable syntax. Via the COLUMNS parameter you then pass the "column" as XMLType to the following XMLtable statement.
    little bit like the following
    select hdjfdf
    from xmltable
       ({xquery}
        PASSING
        COLUMNS xmlfrag xmltype path 'xxx'
       ) a
    ,  xmltable
       ({the other stuff you need}
        PASSING a.xmlfrag
       ...etc
      ...etc                 I guess something simular can be done via XQuery straight away as well

  • How to use multiple outer join in ODI

    SELECT
    Count(*)
    FROM
    student S,
    department D,
    course C
    WHERE
    D.S_Name=S.S_Name
    AND D.Dept_Name = C.Dept_Name (+)
    and S.C_Name =C.C_Name (+)
    And (D.Dept_ID = 1);
    I run this query. I got an ORA-01417 error.

    In topology change the join option to Ordered ISO
    then rewrite your query with ANSI syntax.
    SELECT
    Count(*)
    FROM
    student S join department D on D.S_Name=S.S_Name,
    student S right outer join course C on S.C_Name =C.C_Name,
    department D right outer join course C on S.C_Name =C.C_Name
    where
    (D.Dept_ID = 1);
    First verify the code in sql client befor implementing it in ODI
    Thanks,
    Sutirtha

  • Outer join on query with OR clause

    hi all, i am having problem outerjoining a query with or clause
    here is my data
    WITH table1 AS
    SELECT  'test' txt1, 'pak' txt2, 'ced' txt3, 'su' txt4 FROM dual UNION ALL
    SELECT  null txt1, 'pak' txt2, 'ced2' txt3, 'su2' txt4 FROM dual UNION ALL
    SELECT  null txt1, NULL txt2, 'ced3' txt3, 'su3' txt4 FROM dual UNION ALL
    SELECT  null txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL
    SELECT  'text5' txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL
    SELECT  null txt1, NULL txt2, null txt3, null txt4 FROM dual
    ,table2 AS
    SELECT 111 pid, 'test' txt1, 'pak4' txt2, 'ced' txt3, 'su' txt4 FROM dual UNION ALL
    SELECT 222 pid, 'test1' txt1, 'pak' txt2, 'ced2' txt3, 'su2' txt4 FROM dual UNION ALL
    SELECT 333 pid, 'test2' txt1, 'pak3' txt2, 'ced3' txt3, 'su4' txt4 FROM dual UNION ALL
      SELECT 444 pid, 'test2' txt1, 'pak3' txt2, 'ced4' txt3, 'su3' txt4 FROM dual
    SELECT b.pid, a.*
    from table1 a, table2 b
    WHERE (a.txt1 = b.txt1 OR
           a.txt1 IS NULL AND a.txt2=b.txt2 OR
           Nvl(a.txt2, a.txt1) IS NULL AND a.txt3 = b.txt3 OR
           Nvl(a.txt2, a.txt1) IS NULL  AND a.txt3 IS NULL AND a.txt4 = b.txt4
           ) as you can see i am joining table1 and table 2. i am joining with txt1, if txt1 is null then join by txt2, if null then join by txt3 and so on.
    the code above product this output
    PID     TXT1     TXT2     TXT3     TXT4
    ===     ====     ===   ==== ====
    111     test     pak      ced     su
    222             pak      ced2     su2
    333                     ced3     su3
    444                          su3this output is partially correct. only 4 rows were display and two was left out
    SELECT  'text5' txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL
    SELECT  null txt1, NULL txt2, null txt3, null txt4 FROM dual i tried using outer join but oracle complain that i cannot use outerjoin with OR clause.
    can someone help modify my query to display the output below ?
    PID     TXT1     TXT2     TXT3     TXT4
    ===    ====      ===   ====  ====
    111     test     pak      ced     su
    222             pak      ced2     su2
    333                     ced3     su3
    444                          su3
    NULL  NULL   NULL    NULL   NULL
         test5

    Not sure you can do it with the Oracle style outer joins, but wioth ANSI style joins it is simple, actually exactly as you had it.
    SQL> set null null;
    SQL> WITH table1 AS (
      2   SELECT  'test' txt1, 'pak' txt2, 'ced' txt3, 'su' txt4 FROM dual UNION ALL
      3   SELECT  null txt1, 'pak' txt2, 'ced2' txt3, 'su2' txt4 FROM dual UNION ALL
      4   SELECT  null txt1, NULL txt2, 'ced3' txt3, 'su3' txt4 FROM dual UNION ALL
      5   SELECT  null txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL
      6   SELECT  'text5' txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL
      7   SELECT  null txt1, NULL txt2, null txt3, null txt4 FROM dual),
      8  table2 AS (
      9   SELECT 111 pid, 'test' txt1, 'pak4' txt2, 'ced' txt3, 'su' txt4 FROM dual UNION ALL
    10   SELECT 222 pid, 'test1' txt1, 'pak' txt2, 'ced2' txt3, 'su2' txt4 FROM dual UNION ALL
    11   SELECT 333 pid, 'test2' txt1, 'pak3' txt2, 'ced3' txt3, 'su4' txt4 FROM dual UNION ALL
    12   SELECT 444 pid, 'test2' txt1, 'pak3' txt2, 'ced4' txt3, 'su3' txt4 FROM dual)
    13  SELECT b.pid, a.*
    14  from table1 a
    15     LEFT JOIN table2 b
    16        ON (a.txt1 = b.txt1 OR
    17            a.txt1 IS NULL AND a.txt2=b.txt2 OR
    18            Nvl(a.txt2, a.txt1) IS NULL AND a.txt3 = b.txt3 OR
    19            Nvl(a.txt2, a.txt1) IS NULL  AND a.txt3 IS NULL AND a.txt4 = b.txt4);
           PID TXT1   TXT2   TXT3   TXT4
           111 test   pak    ced    su
           222 null   pak    ced2   su2
           333 null   null   ced3   su3
           444 null   null   null   su3
    null       text5  null   null   su3
    null       null   null   null   nullJohn

  • How to use left outer join on more than one table (source)

    Hi all,
    In our project we are converting the Unix shell & SQL scripts into OWB mappings. We are facing problem converting left outer join in OWB. here is one of the example. i have just pasted the FROM and where condition.
    FROM ym_scr t1, branch_finmonth t3
    LEFT OUTER JOIN item_image t2
    ON (t1.branch_no = t2.branch_no
    AND t1.item_no = t2.item_no
    AND t3.to_date between t2.tran_dt and t2.to_dt
    AND t2.to_dt >= '$start_images' ) <<<========= '$start_images' THIS COMES FROM THE UNIX VARAIBLE ,
    We converts the same when we are putting it in OWB join Operator
    INGRP1.branch_no = INGRP2.branch_no(+)
    AND INGRP1.item_no = INGRP2.item_no(+)
    AND INGRP3.to_date between t2.tran_dt and t2.to_dt
    AND INGRP2.to_dt >= INGRP2.start_images
    But as you see in the OWB opreator we can put left join with INGRP1 with INGRP2.
    We can not make same join with INGRP3 & INGRP4 , becoz it failed saying "you cannot left outer join on more than one table/source".
    so overall this OWB code makes incomplete left outer join as per the above ANSI SQL join in Oracle.
    Bcoz of the problem we are getting less number of rows...........
    SO please please help me on this
    Regards
    Ashok

    Hi.
    I know this topic is here for a while now, but I had the same problem today, searched for help and didn´t find anything.
    Later I figured out how to do this.
    You just have to put the (+) one time, and the OWB converts in an LEFT OUTER JOIN statement.
    For this case, all you have to do is:
    ( INGRP1.branch_no = INGRP2.branch_no(+) AND INGRP1.item_no = INGRP2.item_no AND INGRP2.to_dt >= INGRP2.start_images )
    Regards,
    Godoy

Maybe you are looking for

  • After Downgrading 2012 Cal and RDS can i later "un-Downgrade" back to 2012

    So here is the deal.  I have a system that came shipped with 2008R2 Standard server but had shipped with 2012 5user Cal and 5 user RDS.  (i have no idea why they did that) So i inorder to use my Cals and RDS i had to call MS and downgrade the 2012 Ca

  • Wrong processing code used in inbound processing

    Hi We are on 4.6C and have configured a dist. model for material distribution using message type MATMAS. On receiving end IDOC is properly received but processed with code 51 which is "IDOC Interface not complete for message type". While testing it i

  • Setting classpath in netbeans ide5.0

    i don't know how to set classpath in netbeans ide5.0 for MySQL driver and its jar file.

  • JTable, Clipboard and charset encoding...

    I'm trying to paste data into JTable. Here's a part of the code: private BufferedReader getReaderFromTransferable(Transferable t) throws IOException, UnsupportedFlavorException if (t == null) throw new NullPointerException(); DataFlavor[] dfs = t.get

  • Central system administration (CSA) in solution monitoring

    Hello, I want to configure my solution manager for central system administration (CSA) which is a service provided under solution monitoring of transaction dswp. I couldnt find any documents for this configuration. Could you please help me out.. Rega