Union vs join

hi experts
i am working on a project, In it i procedure has been created using view and two tables. Now this view is using 20 tables in it. It make the process very slow. suggest me should i use joins in it will it improve the performance. and how should i use join for twenty tables.
if any other solution pl suggest me
thanks in advance
regards

The code is very huge
but some of the content is here
REATE OR REPLACE VIEW abc ( TRAN_TYPE,
S_NO, TRAN_CODE, WH_CD, MONTH_YEAR,
YEAR_MONTH, TRAN_DATE, PRD_CD, BAG_CD, ............................,
STO_PARTY, DAM_MAT_ACK_PLANT, DAM_MAT_LOSS_PLANT, OPENING_REL,
RO, LIFTED_RO, AMEND_RO, DESP_DIVERTED_FROM,
DESP_DIVERTED_TO ) AS SELECT
'WH_INV' TRAN_TYPE,
'WH_INV' S_NO,
WH_INV.ROWID TRAN_CODE,
WH_INV.WH_CD,
TO_CHAR(ADD_MONTHS(WH_INV.TRAN_DATE,1),'MMRRRR') MONTH_YEAR,
TO_CHAR(ADD_MONTHS(WH_INV.TRAN_DATE,1),'RRRRMM') YEAR_MONTH,
ADD_MONTHS(WH_INV.TRAN_DATE,1) TRAN_DATE,
WH_INV.PRD_CD,
WH_INV.BAG_CD,
0 TRAN_QTY,
NVL(GIT_CB,0)                          OPENING_TRANSIT,
0 DESPATCH_PLANT,
0 DESPATCH_PLANT_RAIL,
0 DESPATCH_PLANT_ROAD,
0 GROSS_RECEIPT,
0 GROSS_RECEIPT_RAIL,
0 GROSS_RECEIPT_ROAD,
0 MISSING_BAGS,
0 H_T_LOSS,
0 CUT_TORN,
0 CUT_TORN_RAIL,
0 CUT_TORN_ROAD,
0 TRAN_OTHER_STATES,
NVL(SOUND_CB,0)
     +NVL(WET_CB,0)
     +NVL(DAM_CB,0)
     +NVL(SWEEP_CB,0)
     +NVL(CUT_CB,0)
     +NVL(NON_SALEABLE_CB,0)          OPENING_PHYSICAL,
FROM b
UNION ALL
SELECT
'RCPT_D_DESP' TRAN_TYPE,
RCPT_D.RCPT_KEY S_NO,
RCPT_D.ROWID TRAN_CODE,
DA.WH_CD,
TO_CHAR(DA.DA_DT,'MMRRRR') MONTH_YEAR,
TO_CHAR(DA.DA_DT,'RRRRMM') YEAR_MONTH,
DA.DA_DT TRAN_DATE,
RCPT_D.PRD_CD,
RCPT_D.BAG_CD,
0 REL_CB,
0 SOUND_CB,
0 DAM_CB,
0 WET_CB,
0 CUT_CB,
((NVL(RCPT_D.BAG_DESP,0) ) * BAG.PACKING )/ 1000      GIT_CB,
0 GIT_PLANT_ROAD_CB,
((NVL(RCPT_D.BAG_DESP,0) ) * BAG.PACKING )/ 1000      GIT_PLANT_RAIL_CB,
0 GIT_OTHER_
like this 20 tables has been joined.
regards

Similar Messages

  • How to implement Union and Join operations in OBIEE

    Hi all,
    Am new to OBIEE. Can some one tell me the right place to create Union and Joins in OBIEE....
    Do i need to create Union or Join in Oracle(DB level) or do i have the option of creating Union/Join in Physical layer or BMM layer. I tried creating a union in Physical layer,but when i check the the data in presentation layer,i see only data from 1st table.
    Thanks you
    Praveen

    Union - in the physical layer when creating new physical table/table type select:
    Example:
    select 1 as id from dual union all
    select 2 as id from dual
    Joins - You create them in the physical layer (FK, complex) and in the BMM (complex).
    You don't need to create joins in the database.
    Regards
    Goran
    http://108obiee.blogspot.com

  • SQL - JOIN using UNION ?? UNION using JOIN ?? with example!

    I was asked this question during one of my interviews. Can you do JOIN using UNION keyword? Can you do UNION using JOIN keyword?
    That is -
    1. I should get same output as JOIN without using JOIN keyword, but using UNION Keyword?
    2. I should get same output as UNION without using UNION keyword, but using JOIN Keyword?
    Can you give me an example of how to do this if possible?

    Hi,
    Welcome to the forum!
    user13067794 wrote:
    I was asked this question during one of my interviews. Can you do JOIN using UNION keyword? Can you do UNION using JOIN keyword?The correct answer to those questions is: Why would you want to? All versions of Oracle (and probably any other database product) provide JOIN to do certain things and UNION to do other things. Why not use those features the way they were designed to be used? Even if it is possible to do what you ask, it's going to be more complicated and less efficient.
    If you really must:
    That is -
    1. I should get same output as JOIN without using JOIN keyword, but using UNION Keyword? You can select the relevant columns from each table, and NULLs for all the columns from other tables, in a UNION query. Then you can use GROUP BY or analytic functions to combine data from different rows. For example, this JOIN:
    SELECT     d.dname
    ,     e.mgr
    FROM     scott.dept     d
    JOIN     scott.emp     e  ON     d.deptno  = e.deptno
    ;could be written using UNION, but no JOIN, like this:
    WITH     union_data     AS
         SELECT     deptno
         ,     dname
         ,     NULL     AS empno
         ,     NULL     AS mgr
         FROM     scott.dept
        UNION ALL
         SELECT     deptno
         ,     NULL     AS dname
         ,     empno
         ,     mgr
         FROM     scott.emp
    ,     quasi_join     AS
         SELECT     MAX (dname) OVER (PARTITION BY deptno)     AS dname
         ,     mgr
         ,     empno
         FROM     union_data
    SELECT     dname
    ,     mgr
    FROM     quasi_join
    WHERE     empno     IS NOT NULL
    ;Depending on your tables and your requirements, you might be able to do something a little simpler.
    2. I should get same output as UNION without using UNION keyword, but using JOIN Keyword?A FULL OUTER JOIN is similar to UNION.
    This UNION query:
    SELECT     dname          AS txt
    FROM     scott.dept
    UNION
    SELECT     TO_CHAR (mgr)     AS txt
    FROM     scott.emp
    ;Can be written like this, using JOIN but no UNION:
    SELECT DISTINCT
         NVL2 ( e.empno
              , TO_CHAR (e.mgr)
              , d.dname
              )          AS txt
    FROM          scott.dept     d
    FULL OUTER JOIN     scott.emp     e  ON       1 = 2
    user13067794 wrote:I too don't any example as such, but I am thinking on this line -
    Select a.x, b.y
    from a,b
    where a.key=b.key and sal<5000
    UNION
    Select a.x, b.y
    From a,b
    Where a.key=b.key and sal>7000
    can we get same result using JOIN?That's a very special case. You can get the same results without using UNION like this:
    Select distinct
         a.x
    ,      b.y
    from      a
    ,     b
    where      a.key     = b.key
    and      (        sal < 5000
         OR     sal > 7000
    Can we do something similar using UNION without using JOIN keyword??What you posted does not use the JOIN keyword.
    To get the same results without using a join (either with or without the JOIN keyword), you can use UNION together with aggregate or analytic functions, as I showed earlier.
    Edited by: Frank Kulash on Jul 5, 2011 9:01 PM

  • Error while using Group By on 2 Querys joined by union

    Hello Everyone
    I have a situation where in one report i cannot group the data and in another report when i group the data i am unable to view subject area.
    I Had a Complex Request from my client , i have to claculate a report based on 2 dimensions i.e i am calculating 2 measures from one dimension and other 3 measures from other dimension and then using UNION to join both the querys , for the same description the data is being displayed in 2 rows , then i i tried to combine both the querys from union and trying to select from those then i am getting the result and the problem is i am unable to access the subject area , its giving "Either you do not have permission to use the subject area within Answers, or the subject area does not exist." Error , i am unable to add prompts to these request
    I want the investor Grants Row to be displayed in one Column , I am already using Group by in one of the querys.
    Study                      Cost            Approved         Committed                 Earned          Paid Balance
    Investigator Grants 350,000.00 113,770.78 0.00 0.00 0.00
    Investigator Grants 350,000.00 113,770.78 42,403.13 19,905.90 22,497.23
    Labs 23,000.00 0.00 0.00 0.00 0.00
    Study Drug 47,000.00 0.00 0.00 0.00 0.00
    Other 0.00 0.00 0.00 0.00 0.00
    Here is my query
    SELECT "- Protocol"."Protocol #" saw_0, "- Protocol"."Working Title" saw_1, CURRENT_DATE saw_2, "- Administration"."Display Currency Code" saw_3, "- Protocol"."Managing Country" saw_4, "- Protocol".Country saw_5, "- Protocol"."Country OPS" saw_6, "- Protocol"."EU Country" saw_7, "- Protocol"."GCO Region" saw_8, "- Protocol"."GPB Region" saw_9, "- Administration"."Study Cost" saw_10, SUM (IfNull("- Budget and Payment Facts"."Protocol Cost Line Item Amount - Display CCY",0) BY "- Administration"."Study Cost" ) saw_11, SUM(IfNull("- Budget and Payment Facts"."Committed Amount - Display CCY",0) BY "- Administration"."Study Cost") saw_12, SUM(IfNull("- Budget and Payment Facts"."Actual Amount - Display CCY",0) BY "- Administration"."Study Cost") saw_13, SUM(IfNull("- Budget and Payment Facts"."Amount Paid (SP) - Display CCY",0) BY "- Administration"."Study Cost") saw_14, SUM(IfNull("- Budget and Payment Facts"."Actual Amount - Display CCY",0)-IfNull("- Budget and Payment Facts"."Amount Paid (SP) - Display CCY",0) BY "- Administration"."Study Cost") saw_15, CASE WHEN "- Administration"."Study Cost" = 'Other' THEN 1 END saw_16 FROM "SPECTRUM Reporting" WHERE ("- Administration"."Display Currency Code" = 'USD') AND ("- Protocol"."Protocol #" = 'P31248') UNION SELECT "- Protocol"."Protocol #" saw_0, "- Protocol"."Working Title" saw_1, CURRENT_DATE saw_2, "- Administration". "Display Currency Code" saw_3, "- Protocol"."Managing Country" saw_4, "- Protocol".Country saw_5, "- Protocol"."Country OPS" saw_6, "- Protocol"."EU Country" saw_7, "- Protocol"."GCO Region" saw_8, "- Protocol"."GPB Region" saw_9, "- Administration"."Study Cost" saw_10, IfNull("- Budget and Payment Facts"."Protocol Cost Line Item Amount - Display CCY",0) saw_11, IfNull("- Budget and Payment Facts"."Committed Amount - Display CCY",0) saw_12, 0.00 saw_13, 0.00 saw_14, 0.00 saw_15, CASE WHEN "- Administration"."Study Cost" = 'Other' THEN 1 END saw_16 FROM "SPECTRUM Reporting" WHERE ("- Protocol"."Protocol #" = 'P31248') AND ("- Administration". "Display Currency Code" = 'USD') ORDER BY saw_16 DESC
    Any help is appreciated ..!
    ~Srix

    Here is the query i used to group the data but i cannot access Answers with this query
    SELECT saw_0 saw_0, saw_1 saw_1, saw_2 saw_2, saw_3 saw_3, saw_4 saw_4, saw_5 saw_5, saw_6 saw_6, saw_7 saw_7, saw_8 saw_8, saw_9 saw_9, saw_10 saw_10, SUM(saw_11 BY saw_10) saw_11, SUM(saw_12 BY saw_10 ) saw_12, SUM(saw_13 BY saw_10) saw_13, SUM(saw_14 BY saw_10) saw_14, SUM(saw_15 BY saw_10) saw_15, saw_16 saw_16 FROM (SELECT "- Protocol"."Protocol #" saw_0, "- Protocol"."Working Title" saw_1, CURRENT_DATE saw_2, "- Administration"."Display Currency Code" saw_3, "- Protocol"."Managing Country" saw_4, "- Protocol".Country saw_5, "- Protocol"."Country OPS" saw_6, "- Protocol"."EU Country" saw_7, "- Protocol"."GCO Region" saw_8, "- Protocol"."GPB Region" saw_9, "- Administration"."Study Cost" saw_10, SUM (IfNull("- Budget and Payment Facts"."Protocol Cost Line Item Amount - Display CCY",0) BY "- Administration"."Study Cost" ) saw_11, SUM(IfNull("- Budget and Payment Facts"."Committed Amount - Display CCY",0) BY "- Administration"."Study Cost") saw_12, SUM(IfNull("- Budget and Payment Facts"."Actual Amount - Display CCY",0) BY "- Administration"."Study Cost") saw_13, SUM(IfNull("- Budget and Payment Facts"."Amount Paid (SP) - Display CCY",0) BY "- Administration"."Study Cost") saw_14, SUM(IfNull("- Budget and Payment Facts"."Actual Amount - Display CCY",0)-IfNull("- Budget and Payment Facts"."Amount Paid (SP) - Display CCY",0) BY "- Administration"."Study Cost") saw_15, CASE WHEN "- Administration"."Study Cost" = 'Other' THEN 1 END saw_16 FROM "SPECTRUM Reporting" WHERE ("- Administration"."Display Currency Code" = 'USD') AND ("- Protocol"."Protocol #" = 'P31248') AND ("- Payment"."Payment Number"="- Payment"."Related Payment Request Number")
    UNION SELECT "- Protocol"."Protocol #" saw_0, "- Protocol"."Working Title" saw_1, CURRENT_DATE saw_2, "- Administration". "Display Currency Code" saw_3, "- Protocol"."Managing Country" saw_4, "- Protocol".Country saw_5, "- Protocol"."Country OPS" saw_6, "- Protocol"."EU Country" saw_7, "- Protocol"."GCO Region" saw_8, "- Protocol"."GPB Region" saw_9, "- Administration"."Study Cost" saw_10, IfNull("- Budget and Payment Facts"."Protocol Cost Line Item Amount - Display CCY",0) saw_11, IfNull("- Budget and Payment Facts"."Committed Amount - Display CCY",0) saw_12, 0.00 saw_13, 0.00 saw_14, 0.00 saw_15, CASE WHEN "- Administration"."Study Cost" = 'Other' THEN 1 END saw_16 FROM "SPECTRUM Reporting" WHERE ("- Administration"."Display Currency Code" = 'USD') AND ("- Protocol"."Protocol #" = 'P31248')) T GROUP BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6, saw_7, saw_8, saw_9, saw_10 , saw_11, saw_12, saw_13, saw_14, saw_15, saw_16 ORDER BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6

  • Trying to omit duplicate rows in a UNION

    I am trying to omit duplicate rows from my union’ed join of 2 tables but am running into a problem which I am hoping someone can help me with. The following SQL works, but doesn’t omit the dups.
    SELECT service_code, description_txt, effective_date, ROW_NUMBER() OVER (PARTITION BY service_code
    ORDER BY effective_date DESC) AS rn
    FROM
    (SELECT s.service_code, s.effective_date, s.description_txt
    FROM state_code_desc s
    WHERE s.expire_date IS NULL
    AND s.code_type='H'
    AND s.coverage_type='W'
    AND s.geo_area_code='USA'
    AND s.state_abbr='GE'
    UNION
    SELECT f.service_code, f.effective_date, f.description_txt
    FROM fed_code_desc f
    WHERE f.code_type='H'
    AND f.expire_date IS NULL
    ORDER BY service_code
    When I try to add the WHERE RN=1 immediately before the ORDER by service_code (last line of the SQL), I get the following error:
    ORA-00904 – “RN” Invalid identifier
    Can someone out there help me out, please?
    Thanks!
    Janet
    P.S.-I'm running Oracle 9.1

    Just a precesion,
    It is not a question of analytic functions at all
    In fact, column aliases are not usable in tbe same
    query in the WHERE clause.
    SQL> SELECT deptno,COUNT(*) OVER (PARTITION BY deptno) cnt
      2  FROM emp;
        DEPTNO        CNT
            10          2
            10          2
            20          2
            20          2
            30          5
            30          5
            30          5
            30          5
            30          5
    9 rows selected.
    SQL> SELECT deptno,COUNT(*) OVER (PARTITION BY deptno) cnt
      2  FROM emp
      3  WHERE cnt=1;
    WHERE cnt=1
    ERROR at line 3:
    ORA-00904: "CNT": invalid identifier
    SQL> SELECT deptno,sal*100 s,COUNT(*) OVER (PARTITION BY deptno) cnt
      2  FROM emp
      3  WHERE s=100;
    WHERE s=100
    ERROR at line 3:
    ORA-00904: "S": invalid identifier
    SQL> SELECT deptno,sal*100 s,COUNT(*) OVER (PARTITION BY deptno) cnt
      2  FROM emp
      3  WHERE (sal*100)=100;
    no rows selected
    SQL> SELECT deptno,sal*100 s,COUNT(*) OVER (PARTITION BY deptno) cnt
      2  FROM emp
      3  HAVING COUNT(*) OVER (PARTITION BY deptno)=2;
    HAVING COUNT(*) OVER (PARTITION BY deptno)=2
    ERROR at line 3:
    ORA-30483: window  functions are not allowed hereKhurram

  • Re Creating  a chart getting an error with a 'Union All' statement

    Hi
    I have some data to chart with the following fields;
    Product , Jul-08 , Aug-08, Sep-08 etc ...... to Jan-10.
    The PRODUCT field is text showing the numerous Product Names
    The Jul-08 & other month fields have numbers per product that is to be aggregated for that month & plotted on the line graph.
    My SQL to create the first point on the chart is as below;
    select null link, PRODUCT label, SUM(JUL-08) "FFF"
    from "SCHEMANAME"."TABLENAME"
    WHERE PRODUCT = 'FFF'
    GROUP by PRODUCT
    ORDER BY PRODUCT
    This works fine until I want add the second point of this line graph using a 'union all' join as follows;
    select null link, PRODUCT label, SUM(JUL_08) "FFF"
    from "SCHEMANAME"."TABLENAME"
    WHERE PRODUCT = 'FFF'
    UNION ALL
    select null link, PRODUCT label, SUM(AUG_08) "FFF"
    from "SCHEMANAME"."TABLENAME"
    WHERE PRODUCT = 'FFF'
    I can't work out how I can join the other months on the line graph in one series.
    The error is as follows;
    1 error has occurred
    Failed to parse SQL query:
    select null link, PRODUCT label, SUM(OCT_09) "NCDS - STD" from "BI_A_DATA"."CDW_VS_NCDS_CALLS" WHERE PRODUCT = 'NCDS - STD' UNION ALL select null link, PRODUCT label, SUM(NOV_09) "NCDS - LOCAL" from "BI_A_DATA"."CDW_VS_NCDS_CALLS" WHERE PRODUCT = 'NCDS - LOCAL'
    ORA-00937: not a single-group group function
    Certain queries can only be executed when running your application, if your query appears syntactically correct, you can save your query without validation (see options below query source).
    Can anyone assist?
    I want a continuous Line Graph that shows all the months from Jul-08 , Aug-08, Sep-08 etc ...... to Jan-10 for the same product.
    I will then add other series for the other products, Thanks

    OK, I thought each month would be separated by the different months in each selct subquery, but I see what you mean.
    I'm creating a line graph for various PRODUCTS that has a numeric value for each month, from JUL_08 ..... for a number of months.
    I want a LINE graph that shows the different totals each month for that PRODUCT.
    The error advises that there are more values in the SELECT statement than the expected and to use Use the following syntax:
    SELECT LINK, LABEL, VALUE
    FROM ...
    I then went on to use the '[ ]' brackets to separate data but this didn't fix the problem.
    I've changed the script to suit as per your 'PERIOD' addition but now have the error as per below;
    error script
    1 error has occurred
    Invalid chart query: SELECT null link, PRODUCT label, PERIOD, SUM(ABC) FROM (SELECT null link, PRODUCT, 'JUL_08' PERIOD,SUM(JUL_08)ABC FROM BI_A_DATA.APEX_TEST WHERE PRODUCT = 'ABC' GROUP BY PRODUCT UNION ALL SELECT null link, PRODUCT, 'AUG_08' PERIOD,SUM(AUG_08)ABC FROM BI_A_DATA.APEX_TEST WHERE PRODUCT = 'ABC' GROUP BY PRODUCT UNION ALL SELECT null link, PRODUCT, 'SEP_08' PERIOD,SUM(SEP_08)ABC FROM BI_A_DATA.APEX_TEST WHERE PRODUCT = 'ABC' GROUP BY PRODUCT) GROUP BY link, PRODUCT, PERIOD
    Use the following syntax:
    SELECT LINK, LABEL, VALUE
    FROM ...
    Or use the following syntax for a query returning multiple series:
    SELECT LINK, LABEL, VALUE1 [, VALUE2 [, VALUE3...]]
    FROM ...
    LINK URL
    LABEL Text that displays along a chart axis.
    VALUE1, VALUE2, VALUE3... Numeric columns that define the data values.
    Note: The series names for Column and Line charts are derived from the column aliases used in the query.
    My script amended;
    SELECT null link, PRODUCT label, PERIOD, SUM(ABC)
    FROM
    (SELECT null link, PRODUCT, 'JUL_08' PERIOD,SUM(JUL_08)ABC
    FROM BI_A_DATA.APEX_TEST
    WHERE PRODUCT = 'ABC'
    GROUP BY PRODUCT
    UNION ALL
    SELECT null link, PRODUCT, 'AUG_08' PERIOD,SUM(AUG_08)ABC
    FROM BI_A_DATA.APEX_TEST
    WHERE PRODUCT = 'ABC'
    GROUP BY PRODUCT
    UNION ALL
    SELECT null link, PRODUCT, 'SEP_08' PERIOD,SUM(SEP_08)ABC
    FROM BI_A_DATA.APEX_TEST
    WHERE PRODUCT = 'ABC'
    GROUP BY PRODUCT)
    GROUP BY link, PRODUCT, PERIOD

  • Text index for UNION queries.

    Hi All,
    Can anyone please help me in tuning search query mentioned below
    select id from usr1.organizations where lower(ID_official_name)   like  'technology%'
    union
    select id from usr1.organizations where lower(ID_OFFICIAL_NORM_NAME)   like  'technology%'
    union
    select id from usr1.organizations where lower(ID_OFFICIAL_ENG_NAME)   like  'technology%'
    union
    select id from usr1.organizations where lower(ID_OFFICIAL_ENG_NORM_NAME)   like  'technology%'
    union
    select id from usr1.organizations where lower(ID_OFFICIAL_TRANS_NAME)   like  'technology%'
    union
    select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_NAME)   like  'technology%'
    union
    select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_ENG_NAME)   like  'technology%'
    union
    select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_ENG_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_TRANS_NAME)   like  'technology%'
    union
    select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_dba_name)   like  'technology%'
    union
    select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_ENG_NAME)   like  'technology%'
    union
    select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_ENG_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_TRANS_NAME)   like  'technology%'
    union
    select id from usr1.ID_FKA_NAMES where lower(ID_fka_name)   like  'technology%'
    union
    select id from usr1.ID_FKA_NAMES where lower(ID_fkA_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_FKA_NAMES where lower(ID_fkA_ENG_NAME)   like  'technology%'
    union
    select id from usr1.ID_FKA_NAMES where lower(ID_fkA_ENG_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_FKA_NAMES where lower(ID_fkA_TRANS_NAME)   like  'technology%'Here organizations table is the parent table having primary key on id column, and rest all tables are children tables having foreign key on id column referencing to primary key id column in organizations table.
    Planning to implement multiple column(Userdatastore) text index on dummy column appended to organizations table. And write triggers on other child tables to trigger the sync for Text index.
    But not sure whether we can rewrite this above sql query by replacing union into joins, not sure why developer has not done so.
    Can anyone please help me in creating text index for this sql. I do not want to approach cartesian joins as these are having parent-child relationship.
    Oracle Version: 10.2.0.4
    Please let me know if you need more information

    1 .As text index is created in parent table on id column, can we somehow search only from particular columns(Parent or child) by using user_datastore and tags for sectioning it?
    Below are the sql which i need to make use of text index
    select m.id from id_ALIAS_NAMEs an
    join organizations m on(m.id=an.id)
    where lower(ID_ALIAS_NAME)   like  'technology%' and m.id_data_provider<100;
    select M.id,ID_ALIAS_NAME,'ID_ALIAS_NAME' AS NAMETYPE
    from id_alias_names an JOIN organizations m ON m.id=an.id
    where id_data_provider<100 AND coalesce(m.ID_COUNTRY_OF_DOMICILE,m.ID_COUNTRY_OF_INCORPORATION)='US'
    AND LOWER(ID_ALIAS_NAME) like LOWER('TECHNOLOGY%')
    and F_GetFirstWord(ORG_ALIAS_NAME)='TECHNOLOGY'
    The text index must be created on a text column, not a numeric id column. It is common to create it on a dummy column. You can name that column anything you like instead of dummy, like search_columns or some such thing. You can add tags in your procedure, so that your resulting virtual column is like xml data. You can then create a section group, so that you can search within each of those tags. In the example below, I used ctxsys.auto_section_group because it is the simplest to create, but you may get better performance by using another type of section group and naming each individual tag.
    SCOTT@orcl_11gR2> -- tables you already have:
    SCOTT@orcl_11gR2> create table organizations
      2    (id                    number primary key,
      3       id_official_name          varchar2 (10),
      4       id_official_norm_name          varchar2 (10),
      5       id_official_eng_name          varchar2 (10),
      6       id_official_trans_name          varchar2 (10),
      7       id_data_provider          number,
      8       id_country_of_domicile          varchar2 (10),
      9       id_country_of_incorporation  varchar2 (10))
    10  /
    Table created.
    SCOTT@orcl_11gR2> create table id_alias_names
      2    (id                    number references organizations (id),
      3       id_alias_name               varchar2 (10),
      4       id_alias_norm_name          varchar2 (10),
      5       id_alias_eng_name          varchar2 (10),
      6       id_alias_trans_name          varchar2 (10))
      7  /
    Table created.
    SCOTT@orcl_11gR2> create table id_doing_business_as_names
      2    (id                    number references organizations (id),
      3       id_dba_name               varchar2 (10),
      4       id_dba_norm_name          varchar2 (10),
      5       id_dba_eng_name           varchar2 (10),
      6       id_dba_trans_name          varchar2 (10))
      7  /
    Table created.
    SCOTT@orcl_11gR2> create table id_fka_names
      2    (id                    number references organizations (id),
      3       id_fka_name               varchar2 (10),
      4       id_fka_norm_name          varchar2 (10),
      5       id_fka_eng_name           varchar2 (10),
      6       id_fka_trans_name          varchar2 (10))
      7  /
    Table created.
    SCOTT@orcl_11gR2> -- test data:
    SCOTT@orcl_11gR2> insert all
      2  into organizations values (1, 'test', 'name2', 'name3', 'name4', 99, 'US', null)
      3  into organizations values (2, 'name1', 'name2', 'name3', 'name4', 99, null, 'US')
      4  into organizations values (3, 'name1', 'name2', 'name3', 'name4', 99, null, null)
      5  into organizations values (4, 'name1', 'name2', 'name3', 'name4', 101, 'US', 'US')
      6  into organizations values (5, 'technology', 'technology', 'technology', 'technology', 99, 'US', 'US')
      7  select * from dual
      8  /
    5 rows created.
    SCOTT@orcl_11gR2> insert all
      2  into id_alias_names values (1, 'technology', 'name6', 'name7', 'name8')
      3  into id_alias_names values (2, 'technology', 'test', 'name7', 'name8')
      4  into id_alias_names values (3, 'technology', 'name6', 'name7', 'name8')
      5  into id_alias_names values (4, 'technology', 'name6', 'name7', 'name8')
      6  into id_alias_names values (5, 'name5', 'technology', 'technology', 'technology')
      7  select * from dual
      8  /
    5 rows created.
    SCOTT@orcl_11gR2> insert all
      2  into id_doing_business_as_names values (1, 'name9', 'name10', 'name11', 'name12')
      3  into id_doing_business_as_names values (2, 'name9', 'name10', 'name11', 'name12')
      4  into id_doing_business_as_names values (3, 'name9', 'name10', 'test', 'name12')
      5  into id_doing_business_as_names values (4, 'name9', 'name10', 'name11', 'name12')
      6  into id_doing_business_as_names values (5, 'technology', 'technology', 'technology', 'technology')
      7  select * from dual
      8  /
    5 rows created.
    SCOTT@orcl_11gR2> insert all
      2  into id_fka_names values (1, 'name13', 'name14', 'name15', 'name16')
      3  into id_fka_names values (2, 'name13', 'name14', 'name15', 'name16')
      4  into id_fka_names values (3, 'name13', 'name14', 'name15', 'name16')
      5  into id_fka_names values (4, 'name13', 'name14', 'name15', 'test')
      6  into id_fka_names values (5, 'technology', 'technology', 'technology', 'technology')
      7  select * from dual
      8  /
    5 rows created.
    SCOTT@orcl_11gR2> -- revised procedure to join tables with tags:
    SCOTT@orcl_11gR2> create or replace procedure your_proc
      2    (p_rowid in           rowid,
      3       p_clob     in out nocopy clob)
      4  as
      5  begin
      6    for r1 in
      7        (select id,
      8             '<id_official_name>'
      9             || id_official_name
    10             || '</id_official_name><id_official_norm_name>'
    11             || id_official_norm_name
    12             || '</id_official_norm_name><id_official_eng_name>'
    13             || id_official_eng_name
    14             || '</id_official_eng_name><id_official_trans_name>'
    15             || id_official_trans_name
    16             || '</id_official_trans_name>' as tags_and_values
    17         from      organizations
    18         where  rowid = p_rowid)
    19    loop
    20        dbms_lob.writeappend
    21          (p_clob, length (r1.tags_and_values), r1.tags_and_values);
    22        for r2 in
    23          (select '<id_alias_name>'
    24               || id_alias_name
    25               || '</id_alias_name><id_alias_norm_name>'
    26               || id_alias_norm_name
    27               || '</id_alias_norm_name><id_alias_eng_name>'
    28               || id_alias_eng_name
    29               || '</id_alias_eng_name><id_alias_trans_name>'
    30               || id_alias_trans_name
    31               || '</id_alias_trans_name>' as tags_and_values
    32           from   id_alias_names
    33           where  id = r1.id)
    34        loop
    35          dbms_lob.writeappend
    36            (p_clob, length (r2.tags_and_values), r2.tags_and_values);
    37        end loop;
    38        for r3 in
    39          (select '<id_dba_name>'
    40               || id_dba_name
    41               || '</id_dba_name><id_dba_norm_name>'
    42               || id_dba_norm_name
    43               || '</id_dba_norm_name><id_dba_eng_name>'
    44               || id_dba_eng_name
    45               || '</id_dba_eng_name><id_dba_trans_name>'
    46               || id_dba_trans_name
    47               || '</id_dba_trans_name>' as tags_and_values
    48           from   id_doing_business_as_names
    49           where  id = r1.id)
    50        loop
    51          dbms_lob.writeappend
    52            (p_clob, length (r3.tags_and_values), r3.tags_and_values);
    53        end loop;
    54        for r4 in
    55          (select '<id_fka_name>'
    56               || id_fka_name
    57               || '</id_fka_name><id_fka_norm_name>'
    58               || id_fka_norm_name
    59               || '</id_fka_norm_name><id_fka_eng_name>'
    60               || id_fka_eng_name
    61               || '</id_fka_eng_name><id_fka_trans_name>'
    62               || id_fka_trans_name
    63               || '</id_fka_trans_name>' as tags_and_values
    64           from   id_fka_names
    65           where  id = r1.id)
    66        loop
    67          dbms_lob.writeappend
    68            (p_clob, length (r4.tags_and_values), r4.tags_and_values);
    69        end loop;
    70    end loop;
    71  end your_proc;
    72  /
    Procedure created.
    SCOTT@orcl_11gR2> show errors
    No errors.
    SCOTT@orcl_11gR2> -- examples of virtual columns that revised procedure returns:
    SCOTT@orcl_11gR2> declare
      2    v_clob  clob;
      3  begin
      4    for r in
      5        (select rowid, id
      6         from      organizations)
      7    loop
      8        dbms_lob.createtemporary (v_clob, true);
      9        your_proc (r.rowid, v_clob);
    10        dbms_output.put_line (r.id);
    11        dbms_output.put_line (v_clob);
    12        dbms_lob.freetemporary (v_clob);
    13    end loop;
    14  end;
    15  /
    1
    <id_official_name>test</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name3
    </id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><i
    d_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_a
    lias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_d
    ba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_f
    ka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
    2
    <id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
    3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
    id_alias_norm_name>test</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_a
    lias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_d
    ba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_f
    ka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
    3
    <id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
    3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
    id_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_
    alias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>test</id_db
    a_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_fk
    a_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
    4
    <id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
    3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
    id_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_
    alias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_
    dba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_
    fka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>test</id_fka_trans_name>
    5
    <id_official_name>technology</id_official_name><id_official_norm_name>technology</id_official_norm_name><id_official_eng
    _name>technology</id_official_eng_name><id_official_trans_name>technology</id_official_trans_name><id_alias_name>name5</
    id_alias_name><id_alias_norm_name>technology</id_alias_norm_name><id_alias_eng_name>technology</id_alias_eng_name><id_al
    ias_trans_name>technology</id_alias_trans_name><id_dba_name>technology</id_dba_name><id_dba_norm_name>technology</id_dba
    _norm_name><id_dba_eng_name>technology</id_dba_eng_name><id_dba_trans_name>technology</id_dba_trans_name><id_fka_name>te
    chnology</id_fka_name><id_fka_norm_name>technology</id_fka_norm_name><id_fka_eng_name>technology</id_fka_eng_name><id_fk
    a_trans_name>technology</id_fka_trans_name>
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11gR2> -- user_datastore:
    SCOTT@orcl_11gR2> begin
      2    ctx_ddl.create_preference ('your_datastore', 'user_datastore');
      3    ctx_ddl.set_attribute ('your_datastore', 'procedure', 'your_proc');
      4  end;
      5  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11gR2> -- dummy column:
    SCOTT@orcl_11gR2> alter table organizations add (dummy varchar2(1))
      2  /
    Table altered.
    SCOTT@orcl_11gR2> -- index with auto_section_group,
    SCOTT@orcl_11gR2> -- must be on a text column, like dummy, not numeric id column:
    SCOTT@orcl_11gR2> create index your_index
      2  on organizations (dummy)
      3  indextype is ctxsys.context
      4  parameters
      5    ('datastore     your_datastore
      6        section group     ctxsys.auto_section_group')
      7  /
    Index created.
    SCOTT@orcl_11gR2> -- example queries:
    SCOTT@orcl_11gR2> select id
      2  from   organizations
      3  where  contains (dummy, 'technology within id_alias_name') > 0
      4  and    id_data_provider < 100
      5  /
            ID
             1
             2
             3
    3 rows selected.
    SCOTT@orcl_11gR2> select m.id, an.id_alias_name, 'ID_ALIAS_NAME' as nametype
      2  from   id_alias_names an join organizations m on m.id = an.id
      3  where  contains (m.dummy, 'technology within id_alias_name') > 0
      4  and    m.id_data_provider < 100
      5  and    coalesce (m.id_country_of_domicile, m.id_country_of_incorporation) = 'US'
      6  /
            ID ID_ALIAS_N NAMETYPE
             1 technology ID_ALIAS_NAME
             2 technology ID_ALIAS_NAME
    2 rows selected.
    SCOTT@orcl_11gR2>

  • Join two unrelated data sources

    Is it possible to join two unrelated data sourcesin OWB, if yes, how?
    The closest which comes to my mind is union (outer join) thru two proxy expressions with redundant column holders for reciprocal columns.
    But I am thinking, above would lead to excessive wastage.
    So is there a better way possible.
    Rgds,
    Deepak

    Deepak,
    I think there are 2 different things you are trying to achieve:
    1) With a grand total, something along the lines of:
    select emp1.empno
    , emp1.ename
    , count(emp2.empno) count_empno
    from emp1
    , emp2
    This query will retrieve a grant total, and because there is no relationship, you do not need a join condition. You do access the emp table twice.
    OWB would implement this like:
    select emp1.empno
    , emp1.ename
    , (select count(emp2.empno) from emp2) count_empno
    from emp1
    The other thing you seem to like to implement is a join on the customer_id, or similar for the simplified example, say on deptno in the emp table:
    select emp1.empno
    , emp1.ename
    , sum(emp2.sal) dept_sal_sum
    from emp1
    , emp2
    where emp1.deptno = emp2.deptno
    group by emp1.empno
    , emp1.ename -- this does not add anything, but...
    Again, the way OWB would implement this (something similar):
    select emp1.empno
    , emp1.ename
    , (select sum(emp2.sal)
    from emp2
    where emp2.deptno = emp1.deptno
    ) dept_sal_sum
    from emp1
    group by emp1.empno
    , emp1.ename -- this does not add anything, but...
    Anyway, so the way you would create this is by using the same source multiple times, include the aggregates and put in the join conditions appropriately.
    Hope this makes sense... and addresses the issue.
    Mark.

  • Joining 2 reports at answers level, is it possible?

    Hello
    I'd like to know whether it's possible to use 2 separate reports as physical data sets to create a new report by joining them?
    I have report A and Report B, they both have different structure and filters.. I'd like to create a new report using report A.column A = report B.column A.
    Is it possible to achieve at Answers level?
    Thanks for advice

    Nope. Can't do. If the column types are the same types (by this I mean, column 1 of Report A is the same type as column 1 of Report B, etc.) then you can use UNION to join them, but since you said the queries are of different structures, than no. Now it is possible to create dummy columns to force the datatypes to match, but that is something you need to determine if it's feasible.
    The best answer would be to move all the columns into the same Subject Area in the repository.

  • Multiple UNION ALL views within a view returning incorrect records?

    Hi,
    I have a view which selects from multiple views with UNION ALL joining them. If I just select from the larg UNION ALL query I return more records (correct amount) than If I create a view, and select from it.
    e.g.
    SELECT *
    FROM vw_load_1
    UNION ALL
    SELECT *
    FROM vw_load_2
    UNION ALL
    SELECT *
    FROM vw_load_3
    UNION ALL
    SELECT *
    FROM vw_load_4
    UNION ALL
    SELECT *
    FROM vw_load_5
    Returns 405 Records
    but
    CREATE VIEW vw_master_load
    AS
    SELECT *
    FROM vw_load_1
    UNION ALL
    SELECT *
    FROM vw_load_2
    UNION ALL
    SELECT *
    FROM vw_load_3
    UNION ALL
    SELECT *
    FROM vw_load_4
    UNION ALL
    SELECT *
    FROM vw_load_5;
    SELECT COUNT(*)
    FROM vw_master_load
    Returns 307 records
    Can anyone explain why, or how to get around this?
    Oracle version: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production

    Hi,
    Are you saying that you run:
    select count(*) from (
      SELECT *
      FROM vw_load_1
      UNION ALL
      SELECT *
      FROM vw_load_2
      UNION ALL
      SELECT *
      FROM vw_load_3
      UNION ALL
      SELECT *
      FROM vw_load_4
      UNION ALL
      SELECT *
      FROM vw_load_5
    result is: 307 And then you run
      SELECT *
      FROM vw_load_1
      UNION ALL
      SELECT *
      FROM vw_load_2
      UNION ALL
      SELECT *
      FROM vw_load_3
      UNION ALL
      SELECT *
      FROM vw_load_4
      UNION ALL
      SELECT *
      FROM vw_load_5
    returns 405 rowsIf so, that is very strange.
    Can you an example we can re-produce?
    Regards,
    Peter

  • Help with slow union all

    Hi
    The problem Im having is that I had a query on sales order tables that used to take a couple of minutes to run. The user wanted contract orders to be added to the query and these were stored in different tables to the sales orders. I carried out union all joins in views and then applied the query to the views. Unfortunately it now takes 30 minutes to run.
    I apologise for the large post, I am just trying to provide enough information for someone to help me out.
    Any help will be greatly appreciated.
    Thanks
    Stephen
    The original query was:
    SELECT
    C_STD_COST.MAT, C_STD_COST.LAB, C_STD_COST.OHD, ITEM.PC, BILL_HDR.RATE,
    BILL_SO.SO_SHIP_QTY, BILL_SO.SO_SHIP_EXT_AMT, AR_DOC.CUSTOMER,
    BILL_SO.AR_DOC,
    CUS_LOC.NAME, AR_DOC.CREATED_DATE, MEMO.TOT_ORD_QTY, MEMO.UNIT_PRICE,
    MEMO.BOOK_RATE, AR_DOC.AR_DOC_TYPE, MEMO.MEMO_TYPE, BILL_SO.ITEM
    FROM
    AR_DOC, BILL_HDR, CUS_LOC, BILL_SO, ITEM, MEMO, C_STD_COST
    WHERE
    AR_DOC.AR_CCN=BILL_HDR.AR_CCN AND
    AR_DOC.AR_DOC_TYPE=BILL_HDR.AR_DOC_TYPE AND
    AR_DOC.AR_DOC=BILL_HDR.AR_DOC AND
    AR_DOC.CUSTOMER=CUS_LOC.CUSTOMER AND
    AR_DOC.CUS_AR_LOC=CUS_LOC.CUS_LOC AND
    BILL_HDR.AR_CCN=BILL_SO.AR_CCN AND
    BILL_HDR.AR_DOC_TYPE=BILL_SO.AR_DOC_TYPE AND
    BILL_HDR.AR_DOC=BILL_SO.AR_DOC AND
    BILL_SO.ITEM=ITEM.ITEM (+) AND
    BILL_SO.REVISION=ITEM.REVISION (+) AND
    BILL_SO.AR_DOC=MEMO.AR_DOC (+) AND
    BILL_SO.AR_DOC_LINE=MEMO.MEMO_LINE (+) AND
    BILL_SO.AR_CCN=MEMO.SALES_CCN (+) AND
    BILL_SO.AR_DOC_TYPE=MEMO.MEMO_TYPE (+) AND
    ITEM.ITEM=C_STD_COST.ITEM (+) AND
    ITEM.REVISION=C_STD_COST.REVISION (+) AND
    AR_DOC.CREATED_DATE>=TO_DATE ('30-05-2006 00:00:00', 'DD-MM-YYYY
    HH24:MI:SS') AND
    AR_DOC.CREATED_DATE<TO_DATE ('14-06-2006 00:00:00', 'DD-MM-YYYY
    HH24:MI:SS')
    ORDER BY
    AR_DOC.CUSTOMER, ITEM.PCThe explain plan showed:
    SELECT STATEMENT
    SORT                ORDER BY
    MERGE JOIN          OUTER
    SORT                JOIN
    NESTED LOOPS        OUTER
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS        OUTER
    TABLE ACCESS        FULL              BILL_SO       4
    TABLE ACCESS        BY INDEX ROWID    ITEM          5
    INDEX               UNIQUE SCAN       PK_ITEM           UNIQUE
    TABLE ACCESS        BY INDEX ROWID    BILL_HDR      2
    INDEX               UNIQUE SCAN       PK_BILL_HDR       UNIQUE
    TABLE ACCESS        BY INDEX ROWID    AR_DOC        1
    INDEX               UNIQUE SCAN       PK_AR_DOC         UNIQUE
    TABLE ACCESS        BY INDEX ROWID    CUS_LOC       3
    INDEX               UNIQUE SCAN       PK_CUS_LOC        UNIQUE
    TABLE ACCESS        BY INDEX ROWID    MEMO          6
    INDEX               RANGE SCAN        PK_MEMO           UNIQUE
    SORT                JOIN
    TABLE ACCESS        FULL              COST_ITM      8The views I created were:
    CREATE VIEW C_BILL_DET AS
    SELECT
    AR_CCN, AR_DOC_TYPE, AR_DOC, AR_DOC_LINE, ITEM,
    REVISION, SO_SHIP_QTY, SO_SHIP_EXT_AMT, COST1
    FROM
    BILL_SO
    UNION ALL
    SELECT
    AR_CCN, AR_DOC_TYPE, AR_DOC, AR_DOC_LINE, ITEM,
    REVISION, SHIP_QTY, SHIP_EXT_AMT, COST1
    FROM
      CR_BLSH;
    CREATE VIEW C_BILL_HDR AS
    SELECT
    AR_CCN, AR_DOC_TYPE, AR_DOC, RATE
    FROM
    BILL_HDR
    UNION ALL
    SELECT
    AR_CCN, AR_DOC_TYPE, AR_DOC, RATE
    FROM
    CR_BLHD;The new query is:
    SELECT
    C_STD_COST.MAT, C_STD_COST.LAB, C_STD_COST.OHD, ITEM.PC, C_BILL_HDR.RATE,
    C_BILL_DET.SO_SHIP_QTY, C_BILL_DET.SO_SHIP_EXT_AMT, AR_DOC.CUSTOMER,
    C_BILL_DET.AR_DOC,
    CUS_LOC.NAME, AR_DOC.CREATED_DATE, MEMO.TOT_ORD_QTY, MEMO.UNIT_PRICE,
    MEMO.BOOK_RATE, AR_DOC.AR_DOC_TYPE, MEMO.MEMO_TYPE, C_BILL_DET.ITEM
    FROM
    AR_DOC, C_BILL_HDR, CUS_LOC, C_BILL_DET, ITEM, MEMO, C_STD_COST
    WHERE
    AR_DOC.AR_CCN=C_BILL_HDR.AR_CCN AND
    AR_DOC.AR_DOC_TYPE=C_BILL_HDR.AR_DOC_TYPE AND
    AR_DOC.AR_DOC=C_BILL_HDR.AR_DOC AND
    AR_DOC.CUSTOMER=CUS_LOC.CUSTOMER AND
    AR_DOC.CUS_AR_LOC=CUS_LOC.CUS_LOC AND
    C_BILL_HDR.AR_CCN=C_BILL_DET.AR_CCN AND
    C_BILL_HDR.AR_DOC_TYPE=C_BILL_DET.AR_DOC_TYPE AND
    C_BILL_HDR.AR_DOC=C_BILL_DET.AR_DOC AND
    C_BILL_DET.ITEM=ITEM.ITEM (+) AND
    C_BILL_DET.REVISION=ITEM.REVISION (+) AND
    C_BILL_DET.AR_DOC=MEMO.AR_DOC (+) AND
    C_BILL_DET.AR_DOC_LINE=MEMO.MEMO_LINE (+) AND
    C_BILL_DET.AR_CCN=MEMO.SALES_CCN (+) AND
    C_BILL_DET.AR_DOC_TYPE=MEMO.MEMO_TYPE (+) AND
    ITEM.ITEM=C_STD_COST.ITEM (+) AND
    ITEM.REVISION=C_STD_COST.REVISION (+) AND
    AR_DOC.CREATED_DATE>=TO_DATE ('30-05-2006 00:00:00', 'DD-MM-YYYY
    HH24:MI:SS') AND
    AR_DOC.CREATED_DATE<TO_DATE ('14-06-2006 00:00:00', 'DD-MM-YYYY
    HH24:MI:SS')
    ORDER BY
    AR_DOC.CUSTOMER, ITEM.PCThe explain plan is:
    SELECT STATEMENT
    SORT                ORDER BY
    MERGE JOIN          OUTER
    SORT                JOIN
    NESTED LOOPS
    NESTED LOOPS
    MERGE JOIN
    SORT                JOIN
    NESTED LOOPS        OUTER
    NESTED LOOPS        OUTER
    VIEW                                  C_BILL_DET   4
    UNION-ALL
    TABLE ACCESS        FULL              BILL_SO      9
    TABLE ACCESS        FULL              CR_BLSH      10
    TABLE ACCESS        BY INDEX ROWID    ITEM         5
    INDEX               UNIQUE SCAN       PK_ITEM           UNIQUE
    TABLE ACCESS        BY INDEX ROWID    MEMO         6
    INDEX               RANGE SCAN        PK_MEMO           UNIQUE
    SORT                JOIN
    VIEW                                  C_BILL_HDR   2
    UNION-ALL
    TABLE ACCESS        FULL              BILL_HDR     11
    TABLE ACCESS        FULL              CR_BLHD      12
    TABLE ACCESS        BY INDEX ROWID    AR_DOC       1
    INDEX               UNIQUE SCAN       PK_AR_DOC         UNIQUE
    TABLE ACCESS        BY INDEX ROWID    CUS_LOC      3
    INDEX               UNIQUE SCAN       PK_CUS_LOC        UNIQUE
    SORT                JOIN
    TABLE ACCESS        FULL              COST_ITM     8

    I don't understand.
    I try your with statement and get: "end_date" invalid identifier as an error
    I start my query out:
    WITH start_date as
    (select to_date ('08/15/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM') from dual),
    end_date as (select to_date ('08/18/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM) from dual)
    select sales.id, start_date as callstart, end_date as callend
    where sales.created_timestamp >= start_date
    and sales.created_timestamp < end_date
    UNION ALL
    <<<<<<<here is where you take the last select statement and replace sales with manufacturing>>>>>>>>>>>>>
    UNION ALL
    <<<<<<<here is where you take the last select statement and replace sales with engineering>>>>>>>>>>>>>
    and it still fails.

  • Import sql at report

    Hi,
    I would like to make report as a table with this sql rows:
    select sif_sar, count(*)
    from zah_nab
    where dat_zah > '01.08.2008' and vrs_zah_nab='1' and storno="N" and ozn_zah_nab like 'C%' and sif_sar< 10
    group by 1;
    and
    select sif_sar, count(distinct zah_nab.ozn_zah_nab)
    from zah_nab, zah_nab_st
    where dat_zah < '26.08.2008' and dat_zah > '01.08.2008' and vrs_zah_nab='1' and storno="N" and zah_nab.ozn_zah_nab like 'C%'
    and (zah_nab.ozn_zah_nab=zah_nab_st.ozn_zah_nab) and (realizovan="N")and sif_sar< 10
    group by 1;
    and I'll have to colums with 6 rows and numbers selected from our data base.
    Regards,

    Hi Robert
    Do u want the actual SQL text in the report
    or
    Do you want to combine these two sql statements and fetch the data in the report?
    If you want it as in the second question, you can create a command and use union to join these two sql statements and as I can see that there is a group by condition in it, you can simply select the rows first through commnad without using the where and group by conditions and then have the rows grouped by Crystal Reports' group expert and have the conditions in the where clause applied by using the select expert.
    Hope this helps.
    Regards,
    Nikhil

  • To See all the Errors in View

    Hi,
    We have a very big view consists of many unions and joins
    We are getting errors when creating the view. We are getting one error at a time. If we correct and apply again we are getting the next error and so on.
    Is there any ways to see all the errors in this view?

    First Oracle will parse the SQL query which,
    compirsed the View.
    The Parser checks both syntax and semantic analysis
    and if there is any error , immediately it will throws the error. That too the error will throw from bottom - up sequence.
    So I think there is no possible to know all errors
    in one shot.

  • Complex report (Urgent)

    Dear All,
    My requirement is
    Prompt should be like below
    1 prompt:
    Date(Calender) 15 Min Interval
    30 Min Inteval
    2 prompt:
    DateBetween All dates data
    3 prompt:
    DateBetween All month data
    I should create one report it contain all level information like 15 min interval data and 30 min interval data and date and month.
    1.When i select prompt 1 another prompt it shoud have 15 min and 30 min interval column name(like column selector)
    2.When i select prompt 2, another prompt it should have only one value date.based on date it should display the records.
    3.When i select prompt 3, another prompt it should have only one value month.based on date it should display the records.
    How will implement this. Could you explain me step by step
    Thanks

    Hi,
    I guess you are using UNION to join four reports.First thing in each. of the report dont put any sort on any column and apply sort only on result column.
    [nQSError: 59107] Set operation failed due to incompatible sort order
    Set operation failed due to incompatible sort order.
    To resolve the issue
    1)check SORT_ORDER and SORT_ORDER_LOCALE parameters in the NQSCONFIG.INI file.
    2)Then go to database features tab in RPD(I guess its in connection name) and check SORT_ORDER_LOCALE parameter.Make sure that it doesnt match with SORT_ORDER_LOCALE value in NQSCONFIG.INI.
    Please refer to below link for your reference.Above mentioned steps are well illustrated in this link
    1)http://dt365.blogspot.com/2008/11/faced-following-problems-1.html.
    2)http://download.oracle.com/docs/cd/E05554_01/books/AnyInConfig/AnyInConfigNQSConfigFileRef7.html
    3)http://siebel.ittoolbox.com/groups/technical-functional/siebel-analytics-l/error-codes-opr4onwyu9im8tacoi2dl65p-3603401
    Thanks
    Sandeep
    Edited by: Sandeep Saini on Aug 8, 2010 3:42 AM

  • Multi-fact Query

    Hi all,
    Our software group is looking at creating a tool that will query multi-fact star schema environment. What are my options?
    So far, we have 7 fact tables and 6 dimensions (all shared by the facts). There are no aggregate tables.
    My first thought was one large aggregate table, however the dimensions are all normalized to their particular fact table. So, a customer dimension (for instance) would repeat customers if they fall into multiple fact tables. The dimensions are more complicated than that, but you get the idea. There are only two that are truly normalized...and yes one is TIME. :)

    If you have data that shares all the same dimensions, it almost always makes sense to keep it together in a single fact table. The general guideline is only to split out a new fact table if the dimensionality of the data is different.
    Unions and joins typically just end up slowing things down.
    The only exception I've really seen to this rule is when one set of facts has orders of magnitude more data points then the others. I.e. if you have actuals data that has 100 million rows, but budget data (with the same dimensionality) with only 200,000 rows. This doesn't happen often, but I suppose it could potentially occur.
    Scott

Maybe you are looking for