Inner join driving table

Hi,
we have 2 dimension tables and 1 fact table. So our physical query looks like the below:
Select a, b, c....
from
BC_CTR T89740,
M_CTR T49296,
BC_M_FCT T59920
where
T49296.CTR = T59920.M_CTR and
T89740.CTR = T59920.BC_CTR
The problem we face is that BC_CTR table has 300,000 rows. We want OBI to first query on BC_M_FCT and M_CTR tables and then query on BC_CTR table. So query should do something like the below:
Select a, b, c....
from
BC_CTR T89740 inner join
(M_CTR T49296 inner join BC_M_FCT T59920 on T49296.CTR = T59920.M_CTR) on T89740.CTR = T59920.BC_CTR
I tried setting Driving table in BMM to the fact table but this is not changing the query. How can I force the query to be changed ?
Thanks,
Sheela

In the property of a dimension level, you have a field "number of elements at this level" (a count).
Check here :
http://download.oracle.com/docs/cd/E12103_01/books/admintool/admintool_BusModSetup20.html
and serach "number of elements"
It's an equivalent to the number of rows. Therefore if you fill in in the lowest level, it's the number of rows in your table.
The documentation said that :
"This number is used by the Analytics Server when picking aggregate sources. The number does not have to be exact, but ratios of numbers from one logical level to another should be accurate"
But if you think that a table is an aggregate source at the lowest level, it can MAY BE influence the query.
I never try.
But I repeat the best way to improve your query is to gather your database statistics :
http://gerardnico.com/wiki/database/oracle/oracle_db_statistics
because the database will rewrite your sql in any way and you will see no improvement.

Similar Messages

  • How to use Inner join of table as Source in Merge statement in SQL

    Hi All,
        I am trying to make source as multiple tables output using Join while coding there is no any syntax error but when i am executing this statement is giving following error
    Following is the query 
    Merge Into EmpDept Target
    Using (select E.Address,e.Design,e.EmailId,e.EmpId,e.Ename,e.ManagerId, e.Salary,D.DeptId,D.DeptName,D.Location from Employee E Inner join Dept D on E.DeptId=D.DeptId )As Source (Address,Design,EmailId,EmpId,EName,ManagerId,Salary,DeptId,DeptName,Location)
    On Source.EmpId=Target.EmpId
    when not matched then
    Insert (Target.Address,Target.Design,Target.EmailId,Target.EmpId,Target.Ename,Target.ManagerId, Target.Salary,Target.DeptId,Target.DeptName,Target.Location)
    values
    (Address,Design,EmailId,EmpId,EName,ManagerId, Salary,DeptId,DeptName,Location)
    When matched then 
    Update set Target.Address = Source.Address ,Target.Design = Source.Design,Target.EmailId      = Source.EmailId     ,Target.Ename       = Source.Ename      ,Target.ManagerId = Source.ManagerId , Target.Salary        = Source.Salary       ,Target.DeptId      = Source.DeptId      ,Target.DeptName = Source.DeptName ,Target.Location    = Source.Location;
    This is error while executing the above merge statement 
    The insert column list used in the MERGE statement cannot contain multi-part identifiers. Use single part identifiers instead.
    Please suggest me where i am wrong.. 
    Niraj Sevalkar

    MERGE INTO EmpDept Target
    Using (SELECT E.Address,
    e.Design,
    e.EmailId,
    e.EmpId,
    e.Ename,
    e.ManagerId,
    e.Salary,
    D.DeptId,
    D.DeptName,
    D.Location
    FROM Employee E
    INNER JOIN Dept D
    ON E.DeptId = D.DeptId) AS Source (Address, Design, EmailId, EmpId, EName, ManagerId, Salary, DeptId, DeptName, Location)
    ON Source.EmpId = Target.EmpId
    WHEN NOT matched THEN
    INSERT (Address,
    Design,
    EmailId,
    EmpId,
    Ename,
    ManagerId,
    Salary,
    DeptId,
    DeptName,
    Location)
    VALUES (Address,
    Design,
    EmailId,
    EmpId,
    EName,
    ManagerId,
    Salary,
    DeptId,
    DeptName,
    Location)
    WHEN matched THEN
    UPDATE SET Address = Source.Address,
    Design = Source.Design,
    EmailId = Source.EmailId,
    Ename = Source.Ename,
    ManagerId = Source.ManagerId,
    Salary = Source.Salary,
    DeptId = Source.DeptId,
    DeptName = Source.DeptName,
    Location = Source.Location;

  • Inner join 6 tables

    Hello All,
                 I have query optimization required to optimize query.The query consists of 6 tables inner join.Can anybody tell me which is best to optimize this query.

     Hi Lopez, Following is the message shown when i click on the operator
    Physical Operation                       Nest ed Loops
    Logical Operation                           Left Outer Join
    Estimated Execution Mode           Row
    Estimated Operator Cost                0.0000193(0%)
    Estimated I / O Cost                         0
    Estimated Subtree Cost                   0.0202515
    Estimated CPU Cost                          0.0000192
    Estimated Number of Executions   1
    Estimated Number of Rows             4.59298
    Estimated Row Size                        64B
    Node ID                                                0
    Warnings
     No Join Predicate

  • How to 'inner join' internal table or cluster table ??

    Hi,
    when i inner join table BSEG it said is a cluster table can't be inner joined .
    i wonder how i can "inner join" bseg with a internal table such as
    data: begin of i_bseg_trans,
            bukrs like bseg-bukrs,
            gjahr like bseg-gjahr,
            belnr like bseg-belnr,
            total_runtimes like i_runtimes-total,
            already_runtimes like i_runtimes-already,
            left_runtimes like i_runtimes-left,
          end of i_bseg_trans.
    and similar things trouble me  when considering several internal tables .
    thanks for any help!!

    Hi,
    but if there's more than 2 tables,  for example
    data: begin of it_bseg occurs 0,
            bukrs like bseg-bukrs,
            else_1 type i,
         end of it_bseg.
    data: begin of t occurs 0,
            bukrs like bseg-bukrs,
          end of t.
    data: begin of r occurs 0,
            bukrs like bseg-bukrs,
            else type c,
          end of r.
    select bukrs from bkdf into table t.
    select bukrs from bkdf into corresponding fields of table it_bseg.
    select bseg~bukrs      "else_1
    from bseg      "it_bseg
      into table r
      for all entries in t
      where bseg~bukrs = t-bukrs.
          " and it_bseg-bukrs = t-bukrs.
    in the select clause i mean whether there's a method similar to the way just drop the " in my code.
    now my solution is to use another loop on it_bseg, but i think when table amount is large this is really a boring solution.

  • INNER JOIN 4 tables only 2 share 1 column?

    Hey guys,
    It's been a while since I have used SQL but I am getting back into it. Currently I am trying to link 4 tables, but two of the tables share one piece of information, in this case it is the (Royalty) column. I have a lot of columns listed in my SELECT, but
    for this example I will just show you the basic problem. I am receiving this error when I Execute the script:
    "Msg 209, Level 16, State 1, Line 24 Ambiguous column name 'royalty'."
    When I remove the (Royalty) from my SELECT group and just leave my other columns in there, the problem goes away.
    SELECT
    royalty
    FROM 
    stores
    INNER JOIN sales
    ON stores.stor_id=sales.stor_id
    INNER JOIN titles
    ON sales.title_id=titles.title_id
    INNER JOIN roysched
    ON titles.title_id=roysched.title_id
    stor_id and title_id are two keys that I found that have a relationship between these 4 tables. Are you able to link keys or can you only link columns together?

    You need to alias the royalty column.Not sure of your table structure. Its because Royalty is available in more than 1 table, hence the the ambiguity.
    SELECT
    stores.royalty --if royalty is not part of stores, give the correct table name
    FROM 
    stores
    INNER JOIN sales
    ON stores.stor_id=sales.stor_id
    INNER JOIN titles
    ON sales.title_id=titles.title_id
    INNER JOIN roysched
    ON titles.title_id=roysched.title_id

  • Inner join 4 tables

    can anyone give example how to join 4 tables?
      SELECT mara~matnr werks xchar mtart matkl meins trame umlmc
             INTO CORRESPONDING FIELDS OF TABLE t_mat
             FROM mara INNER JOIN marc
             ON maramatnr = marcmatnr
             WHERE mara~matnr IN matnr
               AND werks IN werks
               AND mtart IN matart
               AND matkl IN matkla
               AND ekgrp IN ekgrup
               AND mara~lvorm = lvorm.
    select mblnr mjahr matnr werks
           from mseg
           into table it_mseg
           for all entries in t_mat
           where matnr = t_mat-matnr
       and werks = t_mat-werks.
    select mblnr mjahr budat
           from mkpf
           into table it_mkpf
           for all entries in it_mseg
           where mblnr = it_mseg-mblnr
           and mjahr = it_mseg-mjahr.
    i m adding additional field in the selection screen "BUDAT FROM MKPF'..
    so look at the above code, how i wrote to get the details of bkpf.
    so now i just want one select statement where it picks mara, marc fields along with mkpf-budat.

    Consider these 4 tables. MARA , MARC , MARD , MAKT.
    then select query will be to join all these 4 tables.
    Select AMATNR AMTART BWERKS CEINME CSPEME DMAKTX
              FROM MARA AS A INNER JOIN MARC AS B ON
               AMATNR = BMATNR INNER JOIN MARD AS C ON
               BMATNR = CMATNR INNER JOIN MAKT AS D ON
               CMATNR = DMATNR INTO CORRESPONDING FIELDS OF TABLE 
    ITAB WHERE A~MATNR IN SO_MATNR.
    Note : SO_MATNR is the variable of selection screen.
    Using these select query you can get the field from all 4 tables.
    Pradip Pawar.
    give points if answer is valuable

  • Inner join two tables

    Hi Gurus
    I want to do inner join between two tables to extract customer name
    kna1.kunnr and kna1.name1
    SELECT      FKDAT,  PKUNAG,  NAME1, VRKME, FKIMG, WERKS
    FROM        S903,KNA1 INNER JOIN KNA1
                          ON S903.PKUNAG = KNA1.KUNNR
    WHERE     (S903.WERKS = 'CO01').
    "GROUP BY wg4.S903.FKDAT, wg4.S903.PKUNAG, wg4.KNA1.NAME1, wg4.S903.VRKME, wg4.S903.FKIMG, wg4.S903.WERKS.
    So how can I join s903 with kna1
    regards
    pz

    hi,
    check the condition . i can not found your table and what is co01 .
    SELECT iFKDAT iPKUNAG iVRKME iFKIMG iWERKS mNAME1 into CORRESPONDING FIELDS OF table it
                                                                  from s903  as i
                                                                  inner join kna1 as m on iwerks = mwerks and i~werks in ( 'co01' ).
    if it works pls give me rewards point.
    Regards ,
    pankaj

  • Inner join on four tables

    hi all,
    i am facing the problem with the inner join in the select query for 4 tables.
    can i use the inner join for tables in SAP 6.0 version,
    it is going to dump.
    here is my code
    SELECT DISTINCT apernr abegda aendda awagetype aamount acurrency
            altrctry brufnm banred bvorna bnachn cgroupcode d~vdsk1
    FROM pa9011 AS a INNER JOIN pa0002 AS b ON bpernr = apernr
                      INNER JOIN pa9013 AS c ON cpernr = bpernr
                      inner join pa0001 as d on dpernr = cpernr
                      INTO CORRESPONDING FIELDS OF TABLE it_bonus
    WHERE a~pernr IN s_pernr AND
           a~begda IN s_date AND
           a~subty EQ s_subty AND
           a~wagetype EQ wa_perbonus AND
           a~ltrctry = gc_ind AND
           a~amount > 0 AND
           b~endda = '99991231' AND
           c~groupcode IN s_loc AND
           c~endda = '99991231' and
           d~endda = '99991231'
        ORDER BY a~pernr.

    hi this is the dump ,
    In a SELECT access, the read file could not be placed in the target
    field provided.
    Either the conversion is not supported for the type of the target field,
    the target field is too small to include the value, or the data does not
    have the format required for the target field.

  • MKPF & MSEG Performance issue : Join on table  MKPF & MSEG  taking too much time ..

    Hello Experts,
    I had a issue where we are executing one custom report in which  i used inner join on table  MKPF & MSEG,  some time join statement  took  9-10 min to excute and some time execute within  1-2 min with same test data .
    i am not able to understand what the actaully happing .
    please help.
    code :
       SELECT f~mblnr f~mjahr f~usnam f~bktxt  p~bukrs
        INTO TABLE itab
        FROM mkpf AS f INNER JOIN mseg AS p
            ON f~mblnr = p~mblnr AND f~mjahr = p~mjahr
         WHERE f~vgart = 'WE'
           AND f~budat IN p_budat
           AND f~usnam IN p_sgtxt
           AND p~bwart IN ('101','105')
           AND p~werks IN p_werks
           AND p~lgort IN p_lgort.
    Regards,
    Dipendra Panwar.

    Hi Dipendra,
    if you call a report twice after another with the same test data for data selection, then the second run should be faster, because some data are remaining in memory and needn't to be caught from database. This will be also for the following third und further runs, until the data in the SAP memory will be removed by other programs.
    For performance traces you should try to test with a first run.
    Regards,
    Klaus

  • How to use INNER JOIN in such case

    when i program as below[CASE1]. the code is able to active.
    CASE1:
    ==========================
    DATA: WK_BUKRS LIKE T001-BUKRS,
          WK_BUTXT LIKE T001-BUTXT,
          WK_TABLE(4) TYPE C VALUE 'T001'.
    START-OF-SELECTION.
      WK_BUKRS = 'DECN'.
      PERFORM GET_BUTXT USING WK_BUKRS WK_TABLE
                     CHANGING WK_BUTXT.
      WRITE: WK_BUTXT.
      FORM GET_BUTXT USING I_BUKRS LIKE T001-BUKRS
                           I_TABLE
                  CHANGING O_BUTXT LIKE T001-BUTXT.
        SELECT SINGLE BUTXT
                 INTO O_BUTXT
                 FROM (I_TABLE)
                WHERE BUKRS = I_BUKRS.
      ENDFORM.                   
    ===========================
    but when I need to INNER JOIN another table [CASE2]
    CASE2:
    =======================
    DATA: WK_BUKRS LIKE T001-BUKRS,
          WK_BUTXT LIKE T001-BUTXT,
          WK_TABLE(4) TYPE C VALUE 'T001'.
    START-OF-SELECTION.
      WK_BUKRS = 'DECN'.
      PERFORM GET_BUTXT USING WK_BUKRS WK_TABLE
                     CHANGING WK_BUTXT.
      WRITE: WK_BUTXT.
      FORM GET_BUTXT USING I_BUKRS LIKE T001-BUKRS
                           I_TABLE
                    CHANGING O_BUTXT LIKE T001-BUTXT.
        SELECT SINGLE BUTXT
                 INTO O_BUTXT
                 FROM (I_TABLE) AS G INNER JOIN BKPF AS H
                   ON GBUKRS = HBUKRS
                WHERE G~BUKRS = I_BUKRS.
      ENDFORM.          
    =================================
    Syntax error:
    Wrong expression "INNER" in FROM clause. WHERE condition.
    Can anybody help me to solve the problem.
    My requirement is to use INNER JOIN with variable table

    hi slam,
    chk this sample code.
    hi,
    table emp
    empno name
    a sasi
    b xxx
    c yyy
    table sal
    empno salary
    a 1000
    b 2000
    Inner join
    select eempno ename
    s~sal
    into table int_table
    from emp as e
    inner join sal as s
    on
    eempno = sempno.
    if you made inner join between table a and b by emp no
    the selection retrives only if the condition satisfy the output will be
    a sasi 1000
    b xxx 2000
    rgds
    anver
    if hlped mark points
    Message was edited by: Anversha s

  • Need help with inner join and distinct rows

    Hey Guys,
    i have
    1) BaseEnv Table 
    2) Link Table
    3) BaseData Table
    Link table has three columns Id,BaseEnvId,BaseDataId 
    the BaseEnvID is unique in the table where as BaseDataId can be repeated i.e multile rows of BaseEnv Table can point to same BaseData  table row
    Now i want to do  BaseEnvTable inner join Link Table inner join BaseData Table and select 5 columsn ; Name,SyncName,Version,PPO,DOM  from the BaseData table.. the problem is that after i do the inner join I get duplciate records..
    i want to eliminate the duplicate records , can any one help me here

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
    use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. Now we have to guess and type, guess and type, etc. because of your bad manners. 
    CREATE TABLE Base_Env
    (base_env_id CHAR(10) NOT NULL PRIMARY KEY,
    Think about the name Base_Data; do you have lots of tables without data? Silly, unh? 
    CREATE TABLE Base_Data
    (base_data_id CHAR(10) NOT NULL PRIMARY KEY,
    Your Links table is wrong in concept and implementation. The term “link” refers to a pointer chain structure used in network databases and makes no sense in RDBMS. There is no generic, magic, universal “id” in RDBMS! People that do this are called “id-iots”
    in SQL slang. 
    We can model a particular relationship in a table by referencing the keys in other tables. But we need to know if the relationship is 1:1, 1:m, or n:m. This is the membership of the relationship. Your narrative implies this: 
    CREATE TABLE Links
    (base_env_id CHAR(10) NOT NULL UNIQUE
       REFERENCES Base_Env (base_env_id),
     base_data_id CHAR(10) NOT NULL
       REFERENCES Base_Data (base_data_id));
    >> The base_env_id is unique in the table where as base_data_id can be repeated I.e multiple rows of Base_Env Table can point [sic] to same Base_Data table row. <<
    Again, RDBMS has no pointers! We have referenced an referencing tables. This is a fundamental concept. 
    That narrative you posted has no ON clauses! And the narrative is also wrong. There is no generic “name”, etc. What tables were used in your non-query? Replace the ?? in this skeleton: 
    SELECT ??.something_name, ??.sync_name, ??.something_version, 
           ??.ppo, ??.dom
    FROM Base_Env AS E, Links AS L, Base_Data AS D
    WHERE ?????????;
    >> I want to eliminate the duplicate records [sic], can any one help me here?<<
    Where is the sample data? Where is the results? Please read a book on RDBMS so you can post correct SQL and try again. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Regarding inner join

    I am not getting how to inner join two tables(any two internal tables).
    please give one example.

    Hi,
       Check this,
    data : begin of itab occurs 0,
    matnr like mara-matnr,
    ersda like mara-ersda,
    maktx like makt-maktx,
    end of itab.
    SELECT Amatnr Aersda b~maktx
    INTO itab
    FROM mara AS A INNER JOIN makt AS b
    ON Amatnr = bmatnr
    ENDSELECT.
    Also read this link for understanding,
    http://help.sap.com/saphelp_46c/helpdata/en/cf/21ec77446011d189700000e8322d00/frameset.htm
    Regards

  • Inner join between OBOE and OBOT

    Hi all,
    I am trying to query these tables, but for all the system displays data from these tables in only one windows, MSQL does not inner join this tables.
    So, we are looking for the relation in these two tables, or between OBOE and JDT1/OJDT would be enought.
    Thanks and regards,
    Javier Zapata

    Hi,
    i'm not sure but you can try to use the table BOT1 (Bill of Exchange Transactions details).
    Here you can find the field AbsEntry (related to the table OBOT) and the field BOENumber (related to OBOE table).
    Hope this helps
    Regards,
    Fabio Salucci

  • Inner Join performance problem.

    Hi,
    I wrote a select statement using inner join on table VBRK , VBUK, VBAP and VBRP.
    This select statement is working fine from last two years, but suddenly to execute this select statement
    taking lot of time and program going to dump.
    But same select statement is working in development and quality systems and not working in production system. Based on given selection we check the tables in production we found only 10 records, but to fetch these 10 records also it will taking lot of time and going to dump.
    can anyone please advise on the same.
    Thanks in advance.

    Hi,
    Please:
    1. Create DB view instead of inner join
    2. Use the primary key of the base table (the first or main table in your view) in your where clause
    3. If not possible, then you need to create secondary index in your base table that match with your where clause fields.
    4. Try to use positive relationship operator, like EQ instead NE, GT, etc.
    Hope it helps.
    Lim...

  • Inner join in crystal 2008

    Hi All,
             I am new to Crystal report 2008, i have  a requirement in which i have to make new  connection to Access database which has two tables in it. I have to inner join two tables in crystal reports where the condition is that 1st table contains date and time field and other table has only month. I have to inner join these two fields with key month.Can it be done in crystal reports or i have work on Access itself?
    Regards,
    Vikram Sukumar

    Hi Vikram,
    You should be able to do it in CR as long as the data types are compatibles:
    -Create blank report;
    -From Database Expert, create connection to Access then select the tables to use in the report (if at least 2 tables are selected, the 'Links' tab will appear);
    -Go to 'Links' tab;
    -Drag a field from one table to a field in another table.
    If successful, a link line is created. If unsuccessful, a message is issued.
    Note: You can link tables by table name or by foreign key information.
    Note: When manually creating links, the field you are linking "to" must be of the same data type as the field you are linking from

Maybe you are looking for

  • Creative cloud photoshop blur tool not work as it should be

    creative cloud photoshop blur tool not work as it should be ! I go to blur a painting i am doing and it does not blur enough and I am using wacom Intuos 5 med pen tablet. and I even set the tablets sensitivty for pressure lower then default and still

  • PDF size in CS5

    Query on InDesign CS5: I have brought some old InDesign files from CS4 in to CS5. When I make small sized pdfs in CS5 they are huge in size, but they're fine from CS4. Is there any reason for this? Thanks

  • New user Access

    How to give the new user access  for Hyperion Planning application.Please provide any document  for application access.

  • How to recover deleted SMS

    So a friend was looking at some old texts from my girlfriend that mean a lot to me and she erased the conversation on accident. If I restore my iPhone in iTunes will it return all my texts to what they were at my last sync?? Thanks in advance

  • BC4J can't find existing xml file

    hi, following a debug output with a "file not found" error. the problem is, the file exist. is it possible the container look in root directory? [76] No xml file: /com/eautop/bc/master/master.xml, metaobj = com.eautop.bc.master.masterot directory fol