Joining two tables on two keys of differnt datat types

Hi,
I have two two tables,
create table table1( primkey1 double, name varchar(30))
create table table2( primkey2 varchar(40), name varchar(30))
Now I have to join these two table in RPD. I tried to join but i got an error.
plz tell me the way to join these two tables.
thank you,

Hi,
Please ask the Back End team to change the data type of any of one primary key column. Its always better if you do the change in the Back End
Regards
MuRam

Similar Messages

  • Dynamic SQL Joining between tables and Primary keys being configured within master tables

    Team , Thanks for your help in advance !
    I'm looking out to code a dynamic SQL which should refer Master tables for table names and Primary keys and then Join for insertion into target tables .
    EG:
    INSERT INTO HUB.dbo.lp_order
    SELECT *
    FROM del.dbo.lp_order t1
    where not exists ( select *
    from hub.dbo.lp_order tw
    where t1.order_id = t2.order_id )
    SET @rows = @@ROWCOUNT
    PRINT 'Table: lp_order; Inserted Records: '+ Cast(@rows AS VARCHAR)
    -- Please note Databse names are going to remain the same but table names and join conditions on keys
    -- should vary for each table(s) being configured in master tables
    Sample of Master configuration tables with table info and PK Info :
    Table Info         
    Table_info_ID    Table_Name    
    1        lp_order    
    7        lp__transition_record    
    Table_PK_Info        
    Table_PK_Info_ID    Table_info_ID    PK_Column_Name
    2                1    order_id
    8                7    transition_record_id
    There can be more than one join condition for each table
    Thanks you !
    Rajkumar Yelugu

    Hi Rajkumar,
    It is glad to hear that you figured the question out by yourself.
    There's a flaw with your while loop in your sample code, just in case you hadn't noticed that, please see below.
    --In this case, it goes to infinite loop
    DECLARE @T TABLE(ID INT)
    INSERT INTO @T VALUES(1),(3),(2)
    DECLARE @ID INT
    SELECT @ID = MIN(ID) FROM @T
    WHILE @ID IS NOT NULL
    PRINT @ID
    SELECT @ID =ID FROM @T WHERE ID > @ID
    So a cursor would be the appropriate option in your case, please reference below.
    DECLARE @Table_Info TABLE
    Table_info_ID INT,
    Table_Name VARCHAR(99)
    INSERT INTO @Table_Info VALUES(1,'lp_order'),(7,'lp__transition_record');
    DECLARE @Table_PK_Info TABLE
    Table_PK_Info_ID INT,
    Table_info_ID INT,
    PK_Column_Name VARCHAR(99)
    INSERT INTO @Table_PK_Info VALUES(2,1,'order_id'),(8,7,'transition_record_id'),(3,1,'order_id2')
    DECLARE @SQL NVarchar(MAX),
    @ID INT,
    @Table_Name VARCHAR(20),
    @whereCondition VARCHAR(99)
    DECLARE cur_Tabel_Info CURSOR
    FOR SELECT Table_info_ID,Table_Name FROM @Table_Info
    OPEN cur_Tabel_Info
    FETCH NEXT FROM cur_Tabel_Info
    INTO @ID, @Table_Name
    WHILE @@FETCH_STATUS = 0
    BEGIN
    SELECT @whereCondition =ISNULL(@whereCondition+' AND ','') +'t1.'+PK_Column_Name+'='+'t2.'+PK_Column_Name FROM @Table_PK_Info WHERE Table_info_ID=@ID
    SET @SQL = 'INSERT INTO hub.dbo.'+@Table_Name+'
    SELECT * FROM del.dbo.'+@Table_Name+' AS T1
    WHERE NOT EXISTS (
    SELECT *
    FROM hub.dbo.'+@Table_Name+' AS T2
    WHERE '+@whereCondition+')'
    SELECT @SQL
    --EXEC(@SQL)
    SET @whereCondition = NULL
    FETCH NEXT FROM cur_Tabel_Info
    INTO @ID, @Table_Name
    END
    Supposing you had noticed and fixed the flaw, your answer sharing is always welcome.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Problem encountered when join two remote tables in a materialized view

    I'm using oracle 9.2.0.6
    1> I have two tables:
    CREATE TABLE TEST
    A VARCHAR2(100 BYTE),
    C DATE
    CREATE TABLE TEST1
    A VARCHAR2(100 BYTE),
    B TIMESTAMP
    2>. I defined a prebuild table:
    CREATE TABLE MV_TEST1
    ID1 ROWID,
    A VARCHAR2(100 BYTE),
    ID2 ROWID,
    B TIMESTAMP(6),
    C DATE
    3> I created mview logs:
    CREATE MATERIALIZED VIEW LOG ON PSI_TEST.TEST
    WITH ROWID
    INCLUDING NEW VALUES;
    CREATE MATERIALIZED VIEW LOG ON PSI_TEST.TEST1
    WITH ROWID
    INCLUDING NEW VALUES;
    4> when I create mview:
    CREATE MATERIALIZED VIEW PSI_TEST.MV_TEST1
    ON PREBUILT TABLE WITH REDUCED PRECISION
    REFRESH FAST ON DEMAND
    WITH PRIMARY KEY
    AS
    select
    test.rowid id1,
    test.a,
    test1.rowid id2,
    test1.b,
    cast(null as date) c
    from test , test1
    where test.a = test1.a(+);
    It is created successfully.
    5> problem:
    when I use remote tables to do the same thing, say test and test1 are in another instance and are connected by a dbLink, I couldn't create the mview successfully:
    CREATE MATERIALIZED VIEW PSI_TEST.MV_TEST1
    ON PREBUILT TABLE WITH REDUCED PRECISION
    REFRESH FAST ON DEMAND
    WITH PRIMARY KEY
    AS
    select
    a.rowid id1,
    a.a,
    b.rowid id2,
    b.b,
    cast(null as date) c
    from test@dbl a, test1@dbl b
    where a.a = b.a(+);
    when run above statement, I got:
    ORA-12015: cannot create a fast refresh materialized view from a complex query
    Any ideas? Or joining two table through a dblink for a mview is not allowed at all?
    Thanks in advance.

    No one has a clue?
    Message was edited by:
    lzhwxy

  • Joining two fact tables with different dimensions into single logical table

    Hi Gurus,
    I try to accomplish in Oracle Business Intelligence 11.1.1.3.0:
    F1 (D1, D2 and D3)
    F2 (D1 and D2 and D4)
    And we want to build a report F1 F2 D1 D2 D3 D4 to have data for:
    F1 that match only for D1-D2-D3
    and data for
    F2 that match only D1-D2-D4
    all that in one row, so D3 and D4 are not common dimensions.
    I can only do:
    F3 (D1, D2)
    F4 (D1, D2 and D4)
    And report
    F3 F4 D1,D2,D4 (all that in one row, and only D4 is not a common dimension)
    Here is the very good example how to accomplish the scenario 1
    http://108obiee.blogspot.com/2009/08/joining-two-fact-tables-with-different.html
    But looks like it does not work in 11.1.1.3.0
    I get
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 14025] No fact table exists at the requested level of detail: [,,Clients,,Day,ROI,,,,EW_Names,,,,,,,,,,,,,,,,,]. (HY000)
    I am sure I set up everything correctly as advised in the blog but it works with only one not a common dimension
    Is it a bug in 11.1.1.3.0 or something?
    Thanks,
    Kate

    Thanks for all your replies.
    Actually, I've tried the solutions you guys mentioned. Generally speaking, the result should be displayed. However, my scenario is a little bit tricky.
    table Y's figures are not the aggregation of table X for D dimension. Instead, table Y's figures include not only D dimension total, but also others (others do not mean A, B, C dimension). For example, table Y stores all food's figure, while table X stores only drink's figure. D dimension is only about drink's detail. In my scenario, other foods' figure is not provided.
    So, even if I set D dimension to all/total for table X, table X's result is still not the same as table Y.
    Indeed, table Y does not have a column key to join to D dimension's key. So, if I select D dimension and table Y's measures at the same time in BI Answer, result returns no data. Hence, I can't compare table X and table Y's results with selection of D dimension.
    Is there any solution to solve this problem?
    Edited by: TomChan on Jun 3, 2009 9:36 AM

  • Can we join two totals tables in ABAP Query

    Hey Gurus!
    Can we join two totals tables in ABAP query.
    I am tyring to join FAGFLEXT with internal orders totals table.
    Thanks
    S

    Hi,
    Report painter majorily operates around characteristics and key figures.
    ABAP query comes even more handy.  The advantage is -
    1. You can link many tables
    2. Create selection screen as you like to have
    3. User friendly report creation
    4.  Logic can also be coded.
    5. Authorization can be set
    I have written a article in SDN, which gives you an idea as to how to go about using ABAP query.  Have a look on this - [Article - Practical Usage of ABAP Query|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/20f6b256-23be-2b10-8b93-cad83a617634]
    Regards,
    Sridevi

  • Joining Two Internal Tables - ( Urgent )

    Could anybody please give me the whole code for joining two internal tables
    and putting the data in a third internal table. Please, very urgent.
                                                                                    Regards,
                                                                                    SAURAV

    Hi,
      Refer this code
    *&      Form  SUB_READ_VBRK
          text
    FORM sub_read_vbrk.
      SELECT vbeln
             rplnr
             bukrs
             FROM vbrk
             INTO TABLE it_vbrk
             WHERE vbeln IN s_vbeln
             AND   rplnr NE ' '.
      IF sy-subrc EQ 0.
        SORT it_vbrk BY rplnr.
      ENDIF.
    ENDFORM.                    " SUB_READ_VBRK
    *&      Form  SUB_READ_FPLTC
          text
    FORM sub_read_fpltc.
      IF NOT it_vbrk[] IS INITIAL.
        SELECT fplnr
               fpltr
               ccnum
               FROM fpltc
               INTO TABLE it_fpltc
               FOR ALL ENTRIES IN it_vbrk
               WHERE fplnr EQ it_vbrk-rplnr
               AND   ccins EQ 'GIFC'.
        IF sy-subrc EQ 0.
          SORT it_fpltc BY fplnr.
        ENDIF.
      ENDIF.
    ENDFORM.                    " SUB_READ_FPLTC
    *&      Form  SUB_COLLECT_DATA
          text
    FORM sub_collect_data.
    *--Local variables
      DATA : lv_count(3) TYPE c.
      IF NOT it_fpltc[] IS INITIAL.
        LOOP AT it_fpltc INTO wa_fpltc.
          lv_count = wa_fpltc-fpltr+3(3).
          wa_final-ccnum = wa_fpltc-ccnum.
          wa_final-rfzei = lv_count.
          CLEAR : wa_vbrk.
          READ TABLE it_vbrk INTO wa_vbrk WITH KEY rplnr = wa_fpltc-fplnr
                                                   BINARY SEARCH.
          IF sy-subrc EQ 0.
            wa_final-vbeln = wa_vbrk-vbeln.
            wa_final-bukrs = wa_vbrk-bukrs.
          ENDIF.
          APPEND wa_final TO it_final.
          CLEAR : wa_vbrk,
                  wa_fpltc,
                  lv_count.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " SUB_COLLECT_DATA
    Regards,
    prashant

  • How we relate two tables using foreign key(fk)?

    hi to all,
        what are the conditions has to follow to relate two tables.I.e.,
    the two tables have same primary keys(pk). if we relate these two tables in one table the pk and fk will be the same then how that table in active.

    Hi
    To relate two tables..we have foreign key relationship.
    In one table v have primary key and in the second table, the same key is foreign key for that table..
    To relate two tables, we can use JOINS
    If there is already a suitable foreign key between two tables used in the view, these tables can be linked with a join condition from this foreign key.
    Create a view on tables TAB1 and TAB2. TAB1 is the primary table of the view. TAB2 is the secondary table of the view. TAB1 is the check table for TAB2. The foreign key fields are assigned to the check table fields as follows:
    TAB1-FIELD_A assigned to TAB2-FIELD_1
    TAB1-FIELD_A assigned to TAB2-FIELD_1
    The join condition of the view generated from the foreign key is then:
    CREATE VIEW ... AS SELECT ... WHERE TAB2-FIELD_1 = TAB1-FIELD_A AND TAB2-FIELD_2 = TAB1-FIELD_B.
    Join conditions can also be copied from generic and constant foreign keys. If a constant is assigned to a field in the foreign key, it is also assigned to the field in the join condition. There is no join condition for a generic relationship in the foreign key.
    The foreign key between tables TAB1 (check table) and TAB2 (foreign key table) is defined as follows:
    TAB1-FIELD_A assigned to TAB2-FIELD_1
    TAB1-FIELD_B generic
    TAB1-FIELD_C assigned to constant ‘C’
    The join condition for the view generated from the foreign key is in this case:
    CREATE VIEW ... AS SELECT ... WHERE TAB2-FIELD_1 = TAB1-FIELD_A AND TAB2-FIELD_2 = ‘C’.
    Hope it helps
    Reward if useful.

  • How to join two tables

    hi
    how to join two tables using inner join  if the first table has two primary keys and second table has 3 primary keys

    Would describe type of joins in ABAP, which might differ with other joins.
    The join syntax represents a recursively nestable join expression. A join expression consists of a left-hand and a right- hand side, which are joined either by means of INNER JOIN or LEFT OUTER JOIN. Depending on the type of join, a join expression can be either an inner (INNER) or an outer (LEFT OUTER) join. Every join expression can be enclosed in round brackets. If a join expression is used, the SELECT command circumvents SAP buffering.
    On the left-hand side, either a single database table, a view dbtab_left, or a join expression join can be specified. On the right-hand side, a single database table or a view dbtab_right as well as join conditions join_cond can be specified after ON. In this way, a maximum of 24 join expressions that join 25 database tables or views with each other can be specified after FROM.
    AS can be used to specify an alternative table name tabalias for each of the specified database table names or for every view. A database table or a view can occur multiple times within a join expression and, in this case, have various alternative names.
    The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after the addition WHERE, with the following differences:
    At least one comparison must be specified after ON.
    Individual comparisons may be joined using AND only.
    All comparisons must contain a column in the database table or the view dbtab_right on the right-hand side as an operand.
    The following additions not be used: NOT, LIKE, IN.
    No sub-queries may be used.
    For outer joins, only equality comparisons (=, EQ) are possible.
    If an outer join occurs after FROM, the join condition of every join expression must contain at least one comparison between columns on the left-hand and the right-hand side.
    In outer joins, all comparisons that contain columns as operands in the database table or the view dbtab_right on the right-hand side must be specified in the corresponding join condition. In the WHERE condition of the same SELECT command, these columns are not allowed as operands.
    Resulting set for inner join
    The inner join joins the columns of every selected line on the left- hand side with the columns of all lines on the right-hand side that jointly fulfil the join_cond condition. A line in the resulting set is created for every such line on the right-hand side. The content of the column on the left-hand side may be duplicated in this case. If none of the lines on the right-hand side fulfils the join_cond condition, no line is created in the resulting set.
    Resulting set for outer join
    The outer join basically creates the same resulting set as the inner join, with the difference that at least one line is created in the resulting set for every selected line on the left-hand side, even if no line on the right-hand side fulfils the join_cond condition. The columns on the right-hand side that do not fulfil the join_cond condition are filled with null values.
    Note
    If the same column name occurs in several database tables in a join expression, they have to be identified in all remaining additions of the SELECT statement by using the column selector ~.
    Example
    Join the columns carrname, connid, fldate of the database tables scarr, spfli and sflight by means of two inner joins. A list is created of the flights from p_cityfr to p_cityto. Alternative names are used for every table.
    PARAMETERS: p_cityfr TYPE spfli-cityfrom,
    p_cityto TYPE spfli-cityto.
    DATA: BEGIN OF wa,
    fldate TYPE sflight-fldate,
    carrname TYPE scarr-carrname,
    connid TYPE spfli-connid,
    END OF wa.
    DATA itab LIKE SORTED TABLE OF wa
    WITH UNIQUE KEY fldate carrname connid.
    SELECT ccarrname pconnid f~fldate
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM ( ( scarr AS c
    INNER JOIN spfli AS p ON pcarrid = ccarrid
    AND p~cityfrom = p_cityfr
    AND p~cityto = p_cityto )
    INNER JOIN sflight AS f ON fcarrid = pcarrid
    AND fconnid = pconnid ).
    LOOP AT itab INTO wa.
    WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.
    Example
    Join the columns carrid, carrname and connid of the database tables scarr and spfli using an outer join. The column connid is set to the null value for all flights that do not fly from p_cityfr. This null value is then converted to the appropriate initial value when it is transferred to the assigned data object. The LOOP returns all airlines that do not fly from p_cityfr.
    PARAMETERS p_cityfr TYPE spfli-cityfrom.
    DATA: BEGIN OF wa,
    carrid TYPE scarr-carrid,
    carrname TYPE scarr-carrname,
    connid TYPE spfli-connid,
    END OF wa,
    itab LIKE SORTED TABLE OF wa
    WITH NON-UNIQUE KEY carrid.
    SELECT scarrid scarrname p~connid
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM scarr AS s
    LEFT OUTER JOIN spfli AS p ON scarrid = pcarrid
    AND p~cityfrom = p_cityfr.
    LOOP AT itab INTO wa.
    IF wa-connid = '0000'.
    WRITE: / wa-carrid, wa-carrname.
    ENDIF.
    ENDLOOP.

  • While joining two tables

    Hi all,
    Assume that someone needs to join two tables called PA0002 and PA0008 with keyword PERNR and
    that person needs to read the data of PA0008 aedtm's max.
    That is there are many records based on the aedtm and the user wants to read the last date update and wants to use this in join, not separately.
    Any idea?
    Thanks.
    deniz

    hi use this..
    report.
    tables:pa0002,pa0008.
    data: begin of itab occurs 0,
          pernr like pa0002-pernr,
          vorna like pa0002-vorna,
          nachn like pa0002-nachn,
          begda like pa0002-begda,
          endda like pa0002-endda,
          end of itab.
    data: begin of itab1 occurs 0,
          pernr like pa0008-pernr,
          begda like pa0008-begda,
          stvor like pa0008-stvor,
          ansal like pa0008-ansal,
          end of itab1.
    data:begin of final occurs 0,
          pernr like pa0002-pernr,
          vorna like pa0002-vorna,
          nachn like pa0002-nachn,
          begda like pa0008-begda,
          stvor like pa0008-stvor,
          ansal like pa0008-ansal,
        end of final.
    select-options:s_pernr for pa0002-pernr.
    start-of-selection.
    select pernr
           vorna
           nachn
           begda
           endda
           from pa0002
           into table itab
           where pernr in s_pernr.
    sort itab by pernr begda descending.
    select pernr
           begda
           stvor
           ansal
           from pa0008
           into table itab1
           for all entries in itab
           where pernr = itab-pernr.
    sort itab1 by pernr begda descending.
    loop at itab.
    final-pernr = itab-pernr.
    final-vorna = itab-vorna.
    final-nachn = itab-nachn.
    read table itab1 with key pernr = itab-pernr.
    final-begda = itab1-begda.
    final-stvor = itab1-stvor.
    final-ansal = itab1-ansal.
    append final.
    clear final.
    endloop.
       loop at final.
       write:final-pernr ,
    final-vorna ,
    final-nachn ,
    final-begda ,
    final-stvor ,
    final-ansal .
       endloop.
    regards,
    venkat.

  • Error joining two tables in graph pane

    While trying to join two tables by draging one column onto a column of another table in a graph pane, an error dialog with the following message appears:
    "Drag and drop failed. Please drag a column from one table in the graph onto a column of another table in the graph pane. If you are trying to create a self join, please create another instance of the table and adding same table to the graph pane."
    How do join two tables in the query editor graphically?

    I also have the same problem. I use MySQL. I do not have any foreign keys in my tables. If I try to create table joins graphically myself I get the following error:
    "Drag and drop failed. Please drag a column from one table in the graph onto a column of another table in the graph pane. If you are trying to create a self join, please create another instance of the table and adding same table to the graph pane."
    When I type SQL query(similar to the following) in the in the query editor it dosent work: (As a result same row is appearing more than one time when I test the application)
    WHERE login.USERNAME=me.NAME
    In the above Mayagiri suggested a turorial using Pointbase and tables with foreign keys which is not directly connected with problem.(Beacuse it seems no problems in Pointbase tables with foreign keys)
    Any further is very much appreciated. Thanks in advance.

  • Need help to join two tables using three joins, one of which is a (between) date range.

    I am trying to develop a query in MS Access 2010 to join two tables using three joins, one of which is a (between) date range. The tables are contained in Access. The reason
    the tables are contained in access because they are imported from different ODBC warehouses and the data is formatted for uniformity. I believe this cannot be developed using MS Visual Query Designer. I think writing a query in SQL would be suiting this project.
    ABCPART links to XYZPART. ABCSERIAL links to XYZSERIAL. ABCDATE links to (between) XYZDATE1 and ZYZDATE2.
    [ABCTABLE]
    ABCORDER
    ABCPART
    ABCSERIAL
    ABCDATE
    [ZYXTABLE]
    XYZORDER
    XYZPART
    XYZSERIAL
    XYZDATE1
    XYZDATE2

    Thank you for the looking at the post. The actual table names are rather ambiguous. I renamed them so it would make more sense. I will explain more and give the actual names. What I do not have is the actual data in the table. That is something I don't have
    on this computer. There are no "Null" fields in either of the tables. 
    This table has many orders (MSORDER) that need to match one order (GLORDER) in GLORDR. This is based on MSPART joined to GLPART, MSSERIAL joined to GLSERIAL, and MSOPNDATE joined if it falls between GLSTARTDATE and GLENDDATE.
    [MSORDR]
    MSORDER
    MSPART
    MSSERIAL
    MSOPNDATE
    11111111
    4444444
    55555
    2/4/2015
    22222222
    6666666
    11111
    1/6/2015
    33333333
    6666666
    11111
    3/5/2015
    This table has one order for every part number and every serial number.
    [GLORDR]
    GLORDER
    GLPART
    GLSERIAL
    GLSTARTDATE
    GLENDDATE
    ABC11111
    444444
    55555
    1/2/2015
    4/4/2015
    ABC22222
    666666
    11111
    1/5/2015
    4/10/2015
    AAA11111
    555555
    22222
    3/2/2015
    4/10/2015
    Post Query table
    GLORDER
    MSORDER
    GLSTARTDATE
    GLENDDATE
    MSOPNDATE
    ABC11111
    11111111
    1/2/2015
    4/4/2015
    2/4/2015
    ABC22222
    22222222
    1/5/2015
    4/10/2015
    1/6/2015
    ABC22222
    33333333
    1/5/2015
    4/10/2015
    3/5/2015
    This is the SQL minus the between date join.
    SELECT GLORDR.GLORDER, MSORDR.MSORDER, GLORDR.GLSTARTDATE, GLORDR.GLENDDATE, MSORDR.MSOPNDATE
    FROM GLORDR INNER JOIN MSORDR ON (GLORDR.GLSERIAL = MSORDR.MSSERIAL) AND (GLORDR.GLPART = MSORDR.MSPART);

  • Joining 18 tables -- one at a time or in two stages ?? best one..??

    I have to join 18 tables,.. Is it best to join all 18 in a single shot or to go with
    multi stages-- 9 tables in one stage and after that anotther 9 tables..
    Please anyone give me a good suggestion on this with some reason...
    Thanks in advance

    If you can look at your query and recognise that it is trying to collect (say) two small result sets and then join the result sets, then it is actually a good idea to express the query in that fashion to Oracle.
    Take for example a query that sums last week's profits for a supermarket by department using a 9 table query in about 2 minutes. A similar query reports the previous week's profits with a marginally different query in about two minutes. You write the two queries as inline views and join them to report the percentage change in profit by department - and the query takes 4 hours because Oracle has used "complex view merging" to turn your two 9-table queries into a single 18-table query.
    In this case, a workaround is to use the /*+ no_merge */ hint. In outline, something like:
    select     {columns}
    from
         select /*+ no_merge */
              dept_no,
              etc.
         from     ...
         )     lw,
         select /*+ no_merge */
              dept_no,
              etc.
         from     ...
         )     pw
    where
         pw.dept_no = lw.dept_no
    ;In less obvious cases you may still be able to find that you can break up a big query into a few smaller, logical sections, and use this technique to generate and join what are, in effect, intermediate results.
    An alternative to the /*+ no_merge */ hint is to use subquery factoring to the same end. There's a more complex example of the method here: http://jonathanlewis.wordpress.com/2007/07/01/internet-sql/
    In either case, avoid turning your 18-table query into 18 separate pieces and sticking them back together - it may make the optimizer do some very silly things. Karen Morton mentions an example of this on her blog: http://karenmorton.blogspot.com/2008/06/dont-do-work-you-dont-have-to-do.html
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    "The greatest enemy of knowledge is not ignorance,
    it is the illusion of knowledge." (Stephen Hawking)

  • Using a view to join two tables

    Thank you in advance for any advice you can lend.
    I am using this code in my MySQL db to create a view.
    select
        job.id as job_id,
        umr_cost_calculation.plant_name,
        max(umr_cost_calculation.id) as max_id
    from
        job,
        umr_cost_calculation
    where
        job.id = umr_cost_calculation.job_id
    group by job.id , umr_cost_calculation.plant_name
    I did this so I can join two tables and pull in the most current cost data for a specific plant. The report will, at times, show the wrong (older) data. I can re-run the report, filter to just the one job and see again the wrong data. When I add the max_id to the report, it display the id and updates the report with the correct data. It appears that the view was stale and by adding the ID to the report this fixed the issue.
    1) Is this the best way to make this join? I don't see how Crystal supports a subquery to make a join (this is why I used the view).
    2) If I leave the max_id on the report, will this force the view to always update?

    Try:
    Select
    D1.EmpLoginID,
    Count(D1.ID),
    Count(D1.AlarmCode),
    D1.EmpName,
    D1.EmpAddress,
    D2.Db2Count
    FROM DB1.Data D1
    LEFT JOIN (SELECT
    empLoginID, Count(*) as Db2Count
    FROM DB2.ALL_Database
    WHERE site = 'Atlanta'
    GROUP BY empLoginID
    ) D2
    ON D1.EmpLoginID = D2.EmpLoginID
    GROUP BY D1.empLoginID, D1.EmpName, D2.EmpAddress, D2.Db2Count
    Order BY D1.empLoginID ASC
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • DataType conflict in the R/3 when joining two tables

    Hi Experts,
    I have created a view with two table in the R/3 side by joining two common fields,but one of the field is getting error with different data type, so could any one suggest me how to resolve this issue without changing type.
    Thanks,
    Venugopal

    Hi
    Actually I have to pull one of the  field from one table and place in other table and create a generic data source on it,Can any one suggest me with any solution or exists to solve this issue.
    Thanks,
    Venugopal

  • How do you join two tables from different Oracle schemas using a subquery

    I am trying to join two tables from different Oracle schemas using a subquery. I can extract data from each of the tables without a problem. However, when I combine the select statements using a subquery I get the Oracle error *'ORA-00936: missing expression'*. Since each SELECT statement executes on its own without error I don't understand what is missing. The result set I am trying to get is to match up the LINE_ID from PDTABLE_12_1 in schema DD_12809 with the MAT_DESCRIPTION from table PDTABLE_201 in schema RA_12809.
    The query is as follows:
    sql = "SELECT [DD_12809].[PDTABLE_12_1].LINE_ID FROM [DD_12809].[PDTABLE_12_1] JOIN " _
    + "(SELECT [RA_12809].[PDTABLE_201].MAT_DESCRIPTION " _
    + "FROM [RA_12809].[PDTABLE_201]) AS FAB " _
    + "ON [DD_12809].[PDTABLE_12_1].PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS"
    The format of the query is copied from a SQL programming manual.
    I also tried executing the query using a straight JOIN on the two tables but got the same results. Any insight would be helpful. Thanks!
    Edited by: user11338343 on Oct 19, 2009 6:55 AM

    I believe you are receiving the error because you are trying to JOIN on a column that doesn't exist. For example you are trying to join on FAB.PIPING_MATER_CLASS but that column does not exist in the subquery.
    If you want to do a straight join without a subquery you could do the following
    SELECT  DD_12809.PDTABLE_12_1.LINE_ID
    ,       FAB.MAT_DESCRIPTION
    FROM    DD_12809.PDTABLE_12_1
    JOIN    RA_12809.PDTABLE_201    AS FAB ON DD_12809.PDTABLE_12_1.PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS  HTH!

Maybe you are looking for

  • Code returns "null" and "0"s in main module - why?

    I am coding a program that is in two modules. The main module serves it's standard function. The inventory class/module has three functions - 1) request stock input on 4 data points (1 String and 3 integers, one of which is a double) - 2) calculate t

  • Report on Account Revenue

    I am trying to build an report to see the account Revenues(We have interface to import revenue records from the ERP system to Siebel) Each revenue records is associated with different Products. I am trying to build an reprot like : 'Sales Rep' 'Accou

  • Sony DW U-10A won't read Apple Software DVDs-

    This is on the iMac 17", OS X 10.3.9 Panther, 768MB RAM, 40+ gigs free HD space, no haxies, only Epson printer connected. The internal Sony DW U-10A drive will read CDs, burn CDs, play movie DVDs and burn DVDs but for some reason will not 'see' Apple

  • Not able to connect to database from Report builder

    hello, I installed oracle 9i in my machine and is accessable from SQLPLUS . In the same drive i installed Report builder, i am getting the below error when i tried to connect DB from Report builder. REP-0501: Connecting to the database not specified.

  • Single Path Selection Lag Illustrator CS4

    Running OSX on a MacBook Pro Illustrator CS4 up to date 4gb Ram No significant performance issues anywhere else. Does this happen to anyone else? Draw a path.  Deselect the path.  Use a single click to select the path with the selection tool. For me