3 table join

Hi
Lets say we have following tables
TabA
colA1 (PK)
colA2
colA3
TabB
colB1 (PK)
colA1 (FK - Tab A)
colB2
TabC
colC1 (PK)
colB1 (FK - Tab B)
colA1 (FK - Tab A)
colC2when linking above three tables what is the difference between following two scripts
select * from TabA a, TabB b, TabC c
where a.colA1 = b.colA1 and b.colB1 = c.colB1
select * from TabA a, TabB b, TabC c
where a.colA1 = b.colA1 and b.colB1 = c.colB1 and c.colA1 = a.colA1What is the usage of both
Cheers
Shabar

Hi Shabar
Worked with the sample data.With tow joins data is correct.i.e. it gives us 5 rows
with ft_books as
(select 2800 BK_CODE,'PL/SQL' BK_NAME,'Wembly' BK_PUBLISHER ,'Computer' BK_CATEGORY, 250 AU_CODE from dual
union all
select 2600, 'Data Mining','Wilkinson','Computer',250 from dual
union all
select 1575, 'Deadly Creatures','Williams','Wild Life',150 from dual
union all
select 1500, 'Modern Robotics','Samson','Science',350 from dual
union all
select  2500, 'Database Design','Wilkinson','Computer',250 from dual),
ft_authors as
select 150 AU_CODE,'Wilson'  AU_NAME,'Peters Avenue, New York' AU_ADDS,'USA' AU_COUNTRY from dual
union all
select 350,'Martin Clark','Will street, Paris','France' from dual
union all
select 250,'James Blake','90, 3rd street, London','England' from dual),
ft_book_lons as
select 112 BL_CODE,2800 BL_BK_CODE,20 BL_MEM_ID,'12/08/2010' BL_BWR_DATE,'23/09/2010' BL_RTN_DATE,250 BL_AU_CODE from dual
union all
select  182,2600,33,'12/07/2010','20/09/2010',250 from dual
union all
select 189,1500,33,'12/07/2010','20/09/2010',350 from dual
union all
select 199,1500,19,'06/08/2010','11/10/2010',350 from dual
union all
select 506,1575,13,'06/02/2000','18/07/2000',null from dual
select * from ft_books a,ft_authors b,ft_book_lons c
where a.au_code=b.au_code
and a.bk_code=c.bl_bk_code
Output is
2800     PL/SQL     Wembly     Computer     250     250     James Blake     90, 3rd street, London     England     112     2800     20     12/08/2010     23/09/2010     250
2600     Data Mining     Wilkinson     Computer     250     250     James Blake     90, 3rd street, London     England     182     2600     33     12/07/2010     20/09/2010     250
1500     Modern Robotics     Samson     Science     350     350     Martin Clark     Will street, Paris     France     189     1500     33     12/07/2010     20/09/2010     350
1500     Modern Robotics     Samson     Science     350     350     Martin Clark     Will street, Paris     France     199     1500     19     06/08/2010     11/10/2010     350Now when you add third condition.In that case as the value in ft_book_lons.BL_CODE=506 has bl_au_code as null so when it is comparing with other table value its returning false & hence depreciates one row.
You can modify your query in case of third condiition as below
with ft_books as
(select 2800 BK_CODE,'PL/SQL' BK_NAME,'Wembly' BK_PUBLISHER ,'Computer' BK_CATEGORY, 250 AU_CODE from dual
union all
select 2600, 'Data Mining','Wilkinson','Computer',250 from dual
union all
select 1575, 'Deadly Creatures','Williams','Wild Life',150 from dual
union all
select 1500, 'Modern Robotics','Samson','Science',350 from dual
union all
select  2500, 'Database Design','Wilkinson','Computer',250 from dual),
ft_authors as
select 150 AU_CODE,'Wilson'  AU_NAME,'Peters Avenue, New York' AU_ADDS,'USA' AU_COUNTRY from dual
union all
select 350,'Martin Clark','Will street, Paris','France' from dual
union all
select 250,'James Blake','90, 3rd street, London','England' from dual),
ft_book_lons as
select 112 BL_CODE,2800 BL_BK_CODE,20 BL_MEM_ID,'12/08/2010' BL_BWR_DATE,'23/09/2010' BL_RTN_DATE,250 BL_AU_CODE from dual
union all
select  182,2600,33,'12/07/2010','20/09/2010',250 from dual
union all
select 189,1500,33,'12/07/2010','20/09/2010',350 from dual
union all
select 199,1500,19,'06/08/2010','11/10/2010',350 from dual
union all
select 506,1575,13,'06/02/2000','18/07/2000',null from dual
select * from ft_books a,ft_authors b,ft_book_lons c
where a.au_code=b.au_code
and a.bk_code=c.bl_bk_code
and nvl(b.au_code,0)=nvl(c.bl_au_code,0);
Output is
2800     PL/SQL     Wembly     Computer     250     250     James Blake     90, 3rd street, London     England     112     2800     20     12/08/2010     23/09/2010     250
2600     Data Mining     Wilkinson     Computer     250     250     James Blake     90, 3rd street, London     England     182     2600     33     12/07/2010     20/09/2010     250
1500     Modern Robotics     Samson     Science     350     350     Martin Clark     Will street, Paris     France     189     1500     33     12/07/2010     20/09/2010     350
1500     Modern Robotics     Samson     Science     350     350     Martin Clark     Will street, Paris     France     199     1500     19     06/08/2010     11/10/2010     350Hope it helps!!!
Thanks
AJ

Similar Messages

  • Order Query in SQ01 using Table Joins in CRM

    Hello Experts,
    I am trying to create a query using table joins in SQ01 in CRM because I need a report that will give me all transactions for a selected Business Partner.  I am unable to display any results when running my query.  I have found other threads which give a list of possible tables to join together, but the fields used in the joins were not described. 
    The tables I have joined in my query are as follows:
    CRMD_ORDERADM_H
    CRMD_ORDER_INDEX
    CRMD_PARTNER
    BUT_000
    I have used SE16 to try to search for additional tables to use for linking the Business Partner with a transaction, but I have been unsuccessful.
    Would anyone please give advice as how to proceed? 
    Reward points are available!
    Thank you in advance,
    David

    David
    The link with be the GUID.
    CRMD_ORDERADM_H = Document Header Table
    CRMD_ORDERADM_I = Document Line item Table
    CRMD_LINK = Lists various ‘link’ GUIDs, to
    access order Information
    The Table CRMD_ORDERADM_H will contain you transactions , once you find the GUID of your sales transaction in the table CRMD_ORDERADM_H.
    You then need to check the table CRMD_LINK.
    In this table you will then find a number in 11 = sales. This refers to the table CRMD_SALES. There are also links to many other tables ie Shipping, pricing, org etc.
    CRMM_BUT_SET0140 - for Sales Group, Sales Office, District
    CRMM_BUT_LNK0141 - for Sales Area data
    Transaction CRMD_BUS2000115 allows you to see all sales transactions for a BP. CRMD_BUS2000126 shows you activities for selected BP.
    Regards
    M

  • Context index can't be used in complicated multiple tables join?

    hello
    thank you for view this page.
    i have a comlicated sql :
    SELECT count(*)
    from
    ((app_AssetBasicInfo left join app_AssetBasicInfoExt on
    app_AssetBasicInfo.id=app_AssetBasicInfoExt.id) left join
    (app_AssetCustominfo1 left join app_AssetCustominfoExt1 on
    app_AssetCustominfo1.id=app_AssetCustominfoExt1.id) on
    app_AssetBasicInfo.id=app_AssetCustominfo1.id) WHERE
    app_AssetBasicInfo.CategoryID=1 AND Del_tag=0 and contains(description,'department')>0;
    the table app_AssetBasicInfo and app_AssetBasicInfoExt have multiple columns and large recoord size. i create a context index on app_assetbasicinfoext(description) which description is 4000 varchar2.
    but the sql doesn't use context index. i suspect that the complicated multiple table join can't use context index? does it correct?
    thanks very much!

    Could you please post an explain plan? I'm not quite sure what is the issue.

  • How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?

    1. How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?
    When multiple tables are involved , and the actual number of rows returned is more than what the explain plan tells. How can I find out what change is needed  in the stat plan  ?
    2. Does rowsource statistics gives some kind of  understanding of Extended stats ?

    You can get Row Source Statistics only *after* the SQL has been executed.  An Explain Plan midway cannot give you row source statistics.
    To get row source statistics either set STATISTICS_LEVEL='ALL'  in the session that executes theSQL OR use the Hint "gather_plan_statistics"  in the SQL being executed.
    Then use dbms_xplan.display_cursor
    Hemant K Chitale

  • Using Table.Join formula takes extremly long time to get results.(Why Query Folding doesn't work?)

    Hi,
    I built a query with 4 tables inside (load from Oracle DB and two of them are quite big, more than millions of rows). After filtering, I tried to build relationships between tables using Table.Join formula. However, the process took extremly long time to
    bring out results (I ended the process after 15 mins' processing). There's a status bar kept updating while the query was processing, which is showed as  . I suppose
    this is because the query folding didn't working, so PQ had to load all the data to local memory first then do the opertion, instead of doing all the work on the source system side. Am I right? If yes, is there any ways to solve this issue?
    Thanks.
    Regards,
    Qilong 

    Hi Curt,
    Here's the query that I'm refering,
    let
        Source = Oracle.Database("reporting"),
        AOLOT_HISTS = Source{[Schema="GEN",Item="MVIEW$_AOLOT_HISTS"]}[Data],
        WORK_WEEK = Source{[Schema="GEN",Item="WORK_WEEK"]}[Data],
        DEVICES = Source{[Schema="GEN",Item="MVIEW$_DEVICES"]}[Data],
        AO_LOTS = Source{[Schema="GEN",Item="MVIEW$_AO_LOTS"]}[Data],
        Filter_WorkWeek = Table.SelectRows(WORK_WEEK, each ([WRWK_YEAR] = 2015) and (([WORK_WEEK] = 1) or ([WORK_WEEK] = 2) or ([WORK_WEEK] = 3))), 
        Filter_AlotHists = Table.SelectRows(AOLOT_HISTS, each ([STEP_NAME] = "BAKE" or [STEP_NAME] = "COLD TEST-IFLEX" or [STEP_NAME] = "COLD TEST-MFLEX") and ([OUT_QUANTITY] <> 0)),
        #"Added Custom" = Table.AddColumn(Filter_AlotHists, "Custom", each Table.SelectRows(Filter_WorkWeek, (table2Row) => [PROCESS_END_TIME] >= table2Row[WRWK_START_DATE] and [PROCESS_END_TIME] <= table2Row[WRWK_END_DATE])),
        #"Expand Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"WRWK_YEAR", "WORK_WEEK", "WRWK_START_DATE", "WRWK_END_DATE"}, {"WRWK_YEAR", "WORK_WEEK",
    "WRWK_START_DATE", "WRWK_END_DATE"}),
        Filter_AolotHists_byWeek = Table.SelectRows(#"Expand Custom", each ([WORK_WEEK] <> null)),
        SelectColumns_AolotHists = Table.SelectColumns(Filter_AolotHists_byWeek,{"ALOT_NUMBER", "STEP_NAME", "PROCESS_START_TIME", "PROCESS_END_TIME", "START_QUANTITY", "OUT_QUANTITY", "REJECT_QUANTITY",
    "WRWK_FISCAL_YEAR", "WRWK_WORK_WEEK_NO"}),
        Filter_Devices= Table.SelectRows(DEVICES, each ([DEPARTMENT] = "TEST1")),
        SelectColumns_Devices = Table.SelectColumns(Filter_Devices,{"DEVC_NUMBER", "PCKG_CODE"}),
        Filter_AoLots = Table.SelectRows(AO_LOTS, each Text.Contains([DEVC_NUMBER], "MC09XS3400AFK") or Text.Contains([DEVC_NUMBER], "MC09XS3400AFKR2") or Text.Contains([DEVC_NUMBER], "MC10XS3412CHFK") or Text.Contains([DEVC_NUMBER],
    "MC10XS3412CHFKR2")),
        SelectColumns_AoLots = Table.SelectColumns(Filter_AoLots,{"ALOT_NUMBER", "DEVC_NUMBER", "TRACECODE", "WAFERLOTNUMBER"}),
        TableJoin = Table.Join(SelectColumns_AolotHists, "ALOT_NUMBER", Table.PrefixColumns(SelectColumns_AoLots, "AoLots"), "AoLots.ALOT_NUMBER"),
        TableJoin1 = Table.Join(TableJoin, "AoLots.DEVC_NUMBER", Table.PrefixColumns(SelectColumns_Devices, "Devices"), "Devices.DEVC_NUMBER")
    in
        TableJoin1
    Could you please give me some hints why it needs so long to process?
    Thanks.

  • How to build table join query in Jdeveloper

    Hi,
    Can someone tell me how to build table join query in Jdeveloper's Expression Builder UI?

    [Is it possible to create a table of contents in Crystal Reports?|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313335333133303330%7D.do]

  • Strange behaviour of view based on several tables join with union all

    Dear fellows we r facing a strange problem we have a view based on several tables joined by union all ,when we issue an ordered query on date,rows returned are unusually different than they should be .
    Is oracle has some special behaviour for view based on union all ?
    I m using oracle 8.1.6 on windows 2000
    Kashif Sohail

    Did you ever solve this problem? I have two select statements based on 4 tables and 3 views using about 5 more tables. When I execute each select individually I get exactly what is expected. When I UNION ALL both selects together, I get "no rows returned", however when I UNION them I get exactly what is expected. I should get the same answer for both UNION ALL and UNION. The two select statements are identical, except for one column where I changed the constant to be different. Any thoughts?

  • 3 Table Join with group by and order by clauses

    I am porting from MySQL to Oracle 8i. I have a three Table Join in MySQL as follows:
    select distinct TO_DAYS(l.listend)-TO_DAYS(NOW()) AS daysLeft, i.minbid, l.listend, i.itemid, i.itemtitle, l.listingid, l.lendstart, l.lendend, l.status, MAX(b.amount) AS curBid, COUNT(b.amount) AS numBids from TBL_ITEMS i, TBL_LISTING l LEFT JOIN TBL_BIDS b ON l.listingid=b.listingid where i.itemid = l.itemid AND l.status='1' AND (TO_DAYS(l.listend)-TO_DAYS(NOW()) >= 0) AND i.catcode LIKE'12__' GROUP BY listingid order by curBid DESC, daysLeft;
    It performs an straight join on the first 2 tables (TBL_ITEMS and TBL_LISTING) and a LEFT JOIN between the previous result set and TBL_BIDS. TBL_BIDS uses a group by clause to obtain MAX and COUNT info. This final result set is the sorted (ORDER BY).
    I have tried to reconstruct this type of call in Oracle and have failed. Several problems that I have notices: Oracle does not let me pull in additional columns when doing a GROUP BY clause.
    (see below for my work around)
    I have worked around the problem by creating a TABLE with the group by functionality and doing a straing 3 table join. (NOTE: I cannot create a view because use a LIKE function in the call... view dont have indexes). However, when I try to alias the column that returns DATE subtraction ("l.listend-TRUNC(SYSDATE) daysLeft" OR "l.listend-TRUNC(SYSDATE) dayLeft") I cannot use the LIKE statement.
    Here is my question. How do I port the above 3-table MySQL call to Oracle. Why am I having these problems (is it the Oracle optimizer?) and how do I avaopid them in the future.
    I really appreciate anyone's input. Thanks,
    Inder
    WORK AROUND:
    FIRST STEP:
    "create TABLE BIDSUM as
    select l.listingid, COUNT(b.amount) numBids, MAX(b.amount) curBid from TBL_LISTING l, TBL_BIDS b where l.listingid=b.listingid(+) group by (l.listingid);"
    NEXT STEP:
    select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE), l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode LIKE '12%';
    THIS ALSO WORKS (no LIKE):
    "select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE) daysLeft, l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode='12'";
    BUT THIS DOES NOT (alias the DATE arimetic)
    select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE) daysLeft, l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode LIKE '12__';

    I am porting from MySQL to Oracle 8i. I have a three Table Join in MySQL as follows:
    select distinct TO_DAYS(l.listend)-TO_DAYS(NOW()) AS daysLeft, i.minbid, l.listend, i.itemid, i.itemtitle, l.listingid, l.lendstart, l.lendend, l.status, MAX(b.amount) AS curBid, COUNT(b.amount) AS numBids from TBL_ITEMS i, TBL_LISTING l LEFT JOIN TBL_BIDS b ON l.listingid=b.listingid where i.itemid = l.itemid AND l.status='1' AND (TO_DAYS(l.listend)-TO_DAYS(NOW()) >= 0) AND i.catcode LIKE'12__' GROUP BY listingid order by curBid DESC, daysLeft;
    It performs an straight join on the first 2 tables (TBL_ITEMS and TBL_LISTING) and a LEFT JOIN between the previous result set and TBL_BIDS. TBL_BIDS uses a group by clause to obtain MAX and COUNT info. This final result set is the sorted (ORDER BY).
    I have tried to reconstruct this type of call in Oracle and have failed. Several problems that I have notices: Oracle does not let me pull in additional columns when doing a GROUP BY clause.
    (see below for my work around)
    I have worked around the problem by creating a TABLE with the group by functionality and doing a straing 3 table join. (NOTE: I cannot create a view because use a LIKE function in the call... view dont have indexes). However, when I try to alias the column that returns DATE subtraction ("l.listend-TRUNC(SYSDATE) daysLeft" OR "l.listend-TRUNC(SYSDATE) dayLeft") I cannot use the LIKE statement.
    Here is my question. How do I port the above 3-table MySQL call to Oracle. Why am I having these problems (is it the Oracle optimizer?) and how do I avaopid them in the future.
    I really appreciate anyone's input. Thanks,
    Inder
    WORK AROUND:
    FIRST STEP:
    "create TABLE BIDSUM as
    select l.listingid, COUNT(b.amount) numBids, MAX(b.amount) curBid from TBL_LISTING l, TBL_BIDS b where l.listingid=b.listingid(+) group by (l.listingid);"
    NEXT STEP:
    select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE), l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode LIKE '12%';
    THIS ALSO WORKS (no LIKE):
    "select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE) daysLeft, l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode='12'";
    BUT THIS DOES NOT (alias the DATE arimetic)
    select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE) daysLeft, l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode LIKE '12__';

  • Cost of remote db table join

    How expensive is remote db table join?
    In performance tuning a sql statement, I have a query join a local table to two remote tables, it took 9 sec to return 6000+ rows. If I copy the two remote tables to local db, it took 700 msec. All joins/indexes are identical. The remote db is in the same box as the local db.

    I am only asking for general opinion for experience on remote db table join. From explain plan, I already know it's doing next loop index join on the primary key on the two remote db tables. Only one coluum needed from each remote table. Does it look unusual expensive for 6000 primary key join to remote db tables?. 4 sec for each remote table, added up to 8 sec. The rest of processing is minimal.

  • Table join and Logical databasein a same query

    Hi Experts,
    I have an existing query which is created using table join. I now want to add a logical database in the same infoset.
    Is it possible to add a logical database in the same infoset?
    Regards,
    Prakhar

    Hi Prakhar,
    If you see the  below scren,  you can use data source either Table join using basis table or Logical database.
    but if you need ldb with some addition table field then you can data retrieval by program step or you can use LDB with doing some code in inside  your infoset.
    Regards,
    Prasenjit

  • How to insert a record for tables joined

    Hi,
    first of all I've been learning Forms for few days.
    I've created a simple form where I report the columns from two tables joining them.
    Once I've entered a new list of values in the fields of the form, how can I insert them in the two tables? What I've done, but it doesn't work, is to set "Insert Procedure Name" of the data block = to my procedure compiled in "Program Units" hoping that once pushed the "Execute Query" button in the running form worked, but it didn't work.
    Any advice for the better way to how execute an insert in one or more tables with the content of the fields of the form?
    My versions are: database 10gXE and forms 10.1.2.0.2
    Thanks in advance!

    Hi,
    Create two data blocks using create data block wizard and join it with a relation. Display the fields you want and form will automatically save your updates in the both tables.
    When there is a join you can not update all the fields.
    Regards
    Yoonas
    Edited by: yoonus on Oct 3, 2012 1:04 AM

  • SQVI in a loop when creating or changing table join

    Hello collegues,
    When creating or changing a table join in the sqvi-transaction the transaction is hanging and won't continue. So I can't create any table joins anymore in the system (dev, qas and production-system).
    Earlier I could create and change them without any problems.
    Can anyone help me solving this problem?
    Kind regards and thanks in advance,
    Bart

    Hi Kamal
    You could try the following:
    - for the particular workflow that you are using, find the task that is responsible and then edit the description tab.
    For debugging please go to transaction SE24 and set a breakpoint in CL_BBP_ACTION_NOTIFICATION_WF.
    I hope this helps,
    Kind Regards,
    Lisa

  • Multi-table Join

    I want to join a table with the result of another table join. Is there a syntax to make the first join execute first? Or perhaps I'm going at this all wrong. Any insight would be appreciated. Thanks

    I want to join a table with the result of another table join. Hi,
    Your "other join" is just like a table, so you can do things like this:
    SQL> with t1 as (select 1 x, 'v1' v1 from dual)
      2     , t2 as (select 1 y, 'v2' v2 from dual)
      3     , t3 as (select 1 z, 'v3' v3 from dual)
      4  select *
      5    from t1, (select *
      6                from t2, t3
      7               where t3.z = t2.y) joined
      8   where t1.x = joined.y;
             X V1          Y V2          Z V3
             1 v1          1 v2          1 v3
    [pre]
    Regards
    Peter                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • 3 way table join for a view?

    Hi,
    I need to create a view comprising several complex queries (at least to me...). Below is an example where I have to do a three way table join, based on multiple columns from each table.
    This is the data I need to get at:
    table1."DISTRICT TYPE",
    table1. "DISTRICT CODE",
    table1."EO_NAME"
    With the following constraints:
    table1 joined with table2 via DISTRICT_TYPE and DISTRICT CODE
    table2 joined with table3 via PRECINCT and PRECSUB
    What is the best query to use in this situation? Or, is there a better alternative, considering I do have to create a view?
    Thanks very much.

    This one really is a basic join question, and a quick perusal of the SQL Reference Manual, or any basic SQL book would provide an answer. However ...
    Assuming your tables look like:
    TABLE1
    district_type
    district_code
    eo_name
    TABLE2
    district_type
    district_code
    precinct
    precsub
    TABLE3
    precinct
    precsub
    other_stuff
    then
    SELECT a.district_type, a.district_code, a.eo_name,
           b.precinct, b.precsub,
           c.other_stuff
    FROM table1 a, table2 b, table3 c
    WHERE a.district_type = b.district_type and
          a.district_code = b.district_code and
          b.precinct = c.precinct and
          b.precsub = c.precsub

  • 3 Table Joins -- Need a more efficient Query

    I need a 3 table join but need to do it more efficiently than I am currently doing. The query is taking too long to execute (in excess of 20 mins. These are huge tables with 10 mil + records). Here is what the query looks like right now. I need 100 distinct acctnum from the below query with all the conditions as requirements.
    THANKS IN ADVANCE FOR HELP!!!
    SELECT /*+ parallel  */
      FROM (SELECT  /*+ parallel  */  DISTINCT (a.acctnum),
                                  a.acctnum_status,
                                  a.sys_creation_date,
                                  a.sys_update_date,
                                  c.comp_id,
                                  c.comp_lbl_type,
                                  a.account_sub_type
                  FROM   account a
                         LEFT JOIN
                            company c
                         ON a.comp_id = c.comp_id AND c.comp_lbl_type = 'IND',
                         subaccount s
                 WHERE       a.account_type = 'I'
                         AND a.account_status IN ('O', 'S')
                        and s.subaccount_status in ('A','S')
                         AND a.account_sub_type NOT IN ('G', 'V')
                         AND a.SYS_update_DATE <= SYSDATE - 4 / 24)
    where   ROWNUM <= 100 ;

    Hi,
    Whenever you have a question, post CREATE TABLE and INSERT statements for a little sample data, and the results you want from that data.  Explain how you get those results from that data.
    Simplify the problem, if possible.  If you need 100 distinct rows, post a problem where you only need, say, 3 distinct rows.  Just explain that you really need 100, and you'll get a solution that works for either 3 or 100.
    Always say which version of Oracle you're using (e.g. 11.2.0.3.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    For tuning problems, also see https://forums.oracle.com/message/9362003
    Are you sure the query you posted is even doing what you want?  You're cross-joining s to the other tables, producing all possible combinations of rows, and then picking 100 of those in no particular order (not even random order).  That's not necessarily wrong, but it certainly is suspicious.
    If you're only interested in 100 rows, there's probably some way to write the query so that it picks 100 rows from the big tables first. 

  • Need your help to confirm the table join rules on DocEntry and DocNum.

    Hi guys,
    I've done some study and awared table join rules on SBO documents, let me put in the followings:
    (1) the table of documents head (i.e. ODLN) and line items (i.e. DLN1) can be joined via DocEntry/BaseEntry.
    (2) the table of related documents (i.e. RDR1 and DLN1) can be joined via DocNum/BaseRef.
    finnally, can we say that we can ONLY join table by DocEntry/BaseEntry or DocNum/BaseRef, and we should NOT use DocEntry/BaseRef.
    Am I right? pls help to correct it for my misunderstanding.
    Thanks.

    thanks for your help.
    but I'm truly confused about why some table have both BaseRef and BaseEntry columns, some table only have DocEntry columns?
    As I know, e.g. OWOR and WOR1, there have some series generated from NMM1, the value of DocEntry/DocNum in OWOR may not be the same, and we can only join OWOR/WOR1 via OWOR.DocEntry = WOR1.DocEntry.
    So when to use (T0.DocEntry/T1.DocEntry), when to use (T0.DocEntry/T1.BaseEntry) and when to use (T0.DocNum/T1.BaseRef)?

Maybe you are looking for

  • P&L report (using web interface builder)???

    Hi all, Can someone explain BPS report concept for me? For example, In my P&L report, I will have fixed cost, variable cost, and revenue...etc. I created fixed cost layout, variable cost layout, and revenue layout...etc. My question is <b>how those l

  • How to process a bunch of files

    I am attempting to write a program that will take a list of files to process & process them each in turn. At the moment I have 2 Files declared: File inputFile=new File("default.asc"); File outputFile=new File("default.txt"); The idea is that the use

  • Excise amt not updating in J1IIN (STO)

    Hello everybody, We are facing issue in excise invoice in stock transfer order scenario. We are doing following process- 1) Me21n with order type UB (stock transfer order) 2) VL10B 3)VL02n (PGI) 4) VF01 (for proforma invoice) now when we do J1IIN, sy

  • Can't change Google Talk name in Messages

    I'm having trouble changing my displayed name in Messages in Google Chat. In "Internet Accounts", I only have my iCloud account and my Google account, both of which say my name. Additionally, in Messages, all of my accounts say my name. However, my b

  • Weblogic Portal 10.3 Asynchronous desktop Maximize portlet breaks EXT JS

    Hi, We have enabled Asynchronous desktop & using maximize/restore feature for portlets. We are extensively using EXT JS in our application. Page loads fine when its refreshed but when we use maximize ( url is placed within bea.wlp.disc.xie._service.u