Help with joining one table to several

I have the following table
MSELECT
Res_ID
Res_type
34
501
56
501
72
501
81
502
90
502
100
502
47
503
48
503
The RES_ID will link to different tables such as tablea, tableb or tablec based on the RES_Type value .g. RES_Type ID 501 will link to tableA and 502 will link to TableB and 503 will link to TableC.
I have created the following query:
Select * from MSSELECT MSEL
Inner join tablea  ta on
Ta.id = MSEL.ID and
Res_type = 501
Inner join tableb tb on
Tb.id = MSEL.ID and
Res_type = 501
If I run the following query then results are returned.
 Select * from MSSELECT MSEL
Inner join tablea  ta on
Ta.id = MSEL.ID and
Res_type = 501
However if I run the following query it is returning no results:
Select * from MSSELECT MSEL
Inner join tablea  ta on
Ta.id = MSEL.ID and
Res_type = 501
Inner join tableb tb on
Tb.id = MSEL.ID and
Res_type = 501

Try:
Select * from MSSELECT MSEL
LEFT OUTER join tablea  ta on
Ta.id = MSEL.ID and
Res_type = 501
LEFT OUTER  join tableb tb on
Tb.id = MSEL.ID and
Res_type = 501
Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered.

Similar Messages

  • I need your help with buying one of your software programs.

    I need your help with buying one of your software programs.
    First of all I do not want to join this “Creative Cloud” for a monthly plan.
    Adobe Illustrator CS6 is what I am wanting but every time I click on the buy button is keeps sending me to a rent page to use but I don’t want this I want to buy it program for my own use. I don’t want to rent it I want to buy it like all the other Adobe software programs that I have bought from you in the past.
    Can you help with problem?
    Tim Adams
    [email protected]

    You can buy CS6 from this page
    Creative Suite 6

  • Update statement with joining other tables

    Hi ,
    I have two table one is containing xml file , basically i need to read from those xml file then update to another table based on some condition.
    UPDATE TRCB_XBRL_STG_2 STG
    SET PROFIT =
      case when xbrl.isconsolidatedacc='Y' and EXTRACTVALUE(XBRL.XBRLFILE,'//PROFIT ', 'xmlns:acra="..."') is not null
      THEN EXTRACTVALUE(XBRL.XBRLFILE,'//PROFIT ', 'xmlns:acra="..."')
      WHEN XBRL.ISCONSOLIDATEDACC='N' AND EXTRACTVALUE(XBRL.XBRLFILE,'//PROFIT ', 'xmlns:acra="..') IS NOT NULL
      THEN extractValue(XBRL.xbrlfile,'//PROFIT ', 'xmlns:acra=".."')
      ELSE STG.PROFIT
      END,
      SET REVENUE=
      case when xbrl.isconsolidatedacc='Y' and EXTRACTVALUE(XBRL.XBRLFILE,'//REVENUE', 'xmlns:acra="..."') is not null
      THEN EXTRACTVALUE(XBRL.XBRLFILE,'//REVENUE.', 'xmlns:acra="..."')
      WHEN XBRL.ISCONSOLIDATEDACC='N' AND EXTRACTVALUE(XBRL.XBRLFILE,'//REVENUE', 'xmlns:acra="..') IS NOT NULL
      THEN extractValue(XBRL.xbrlfile,'//REVENUE', 'xmlns:acra="REVENUE"')
      ELSE STG.REVENUE
      END,
      ... (around 100 columns)
    FROM  TRCB_XBRL xbrl ,TRCB_XBRL_STG_2 STG
    WHERE STG.XBRL_ID = XBRL.XBRL_ID Number of columns are around 100 , please anyone suggest how to use update statement with joining two tables.

    Hi,
    If all the values needed to update a given row of table_x are coming from the same row of table_y (or from the same row of a result set of a query involving any number of tables), then you can do something like this:
    UPDATE  table_x  x
    SET     (col1, col2, col3, ...)
    =     (
             SELECT  NVL (y.col1, x.col1)
             ,         NVL (y.col2, x.col2)
             ,         NVL (y.col3, x.col3)
             FROM    table_y  y
             WHERE   x.pkey   = y.expr
             AND         ...
    WHERE   ...
    ;If the WHERE clause depends on the same row of table_y, then it will probably be simpler and more efficient to use MERGE instead of UPDATE.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • Is it possible to make a search help with dynamic  selection table?

    Hi Experts,
    Is it possible to create search helps with dynamic seletion tables means
    i dont know the selection table names at the time of creation of search help.
    These tables will be determined at runtime.
    if yes, Please give an idea how to create and pass the table names at runtime.
    Thanks
    Yogesh Gupta

    Hi Yogesh,
    Create and fill your itab and show it with FM F4IF_INT_TABLE_VALUE_REQUEST
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield        = 'field to return from itab'
          dynpprog        = sy-repid
          dynpnr          = sy-dynnr
          dynprofield     = 'field on your screen to be filled'
          stepl           = sy-stepl
          window_title    = 'some text'
          value_org       = 'S'
        TABLES
          value_tab       = itab
        EXCEPTIONS
          parameter_error = 1
          no_values_found = 2
          OTHERS          = 3.
    Darley

  • I have problem with my iphone 4s my battery is not keeping charge. how can I get help with this one. it is less than a year that I purchased this cell.

    I have problem with my iphone 4s my battery is not keeping charge. how can I get help with this one? it is less than a year that I purchased this cell.

    I would like to know the answer to that one.  I realized this was happening just after upgradeing my iOS to 6.  Then when I looked up my purchase date, I was about 5 days past my one year warranty.  So I'm dead in the water.  Apple will replace the battery, but it will be about $80+.  I took it to the Apple store, and they checked a bunch of stuff, but said that it seemed ok.  I'm debating getting a battery for a more reasonable price off of ebay.  But if it's the iOS thats draining the battery, then I'm not going to be able to help it.  I wish I knew a better way to tell if its the battery, the phone, or the iOS.

  • Help with Joining a few tables

    I need a help using JOINS. I plan to create ONE VIEW by bringing in all fields from First and Second table and a few chosen columns from Third, Fourth and Fifth tables. I have put to together below select statement which appears to be working syntax-wise but not efficient and may have dupes.
    Table1 - RPT_APRL_PRODUCT with key field KEY_MATERIAL (KEY_MATERIAL = DIVISION||PLAN_CTRY||MKT_TYP_ID||MATERIAL)
    Table 2 - RPT_FWEQ_PRODUCT with key field KEY_MATERIAL (KEY_MATERIAL = DIVISION||PLAN_CTRY||MATERIAL)
    Table 3 - NSC_PROD_CIMG has a Key Field = MATERIAL_NBR
    Table 4- STAGE#EMEA_NSAP.NSC_PROD_REG_CIMG has the Key field MATERIAL_NBR, REG_ID
    Table 5 - STAGE#EMEA_NSAP.NSC_PROD_REG_CYC_CIMG has Key Fields MATERIAL_NBR, REG_ID, CYC_ID and ORGVERSIONID
    Columns needed from Table 3 -- B.DIVISION, B.DIVISIONNAME, B.SUBLABEL, B.SUBLABELNAME and B.DEVELOPMENTREGION.
    Columns needed from Table 4 --- C.GLOBALSOURCEINDICATOR
    Columns needed from Table 5--- D.CARRYOVERFLAG
    SELECT statement:
    SELECT /*+ parallel (a,5) parallel (NET,5) */
    a.key_material,
    a.mkt_typ_id,
    a.region_id,
    CASE
    WHEN a.region_id = '3' THEN 'USA'
    WHEN a.region_id = '4' THEN 'EMEA'
    WHEN a.region_id = '7' THEN 'CANADA'
    END AS region_desc,
    a.mkt_reg_cd,
    CASE
    WHEN a.mkt_reg_cd = '01' THEN 'USA'
    WHEN a.mkt_reg_cd = '02' THEN 'EMEA'
    WHEN a.mkt_reg_cd = '05' THEN 'AMER'
    END AS mkt_reg_desc,
    a.cat_bus_cd1,
    a.cat_bus_desc1,
    a.cat_bus_cd2,
    a.cat_bus_desc2,
    a.cat_bus_cd3,
    a.cat_bus_desc3,
    a.cat_bus_cd4,
    a.cat_bus_desc4,
    a.mkstr_cd,
    a.mkt_clsfn_desc,
    a.mkt_clsfn_cd1,
    a.mkt_clsfn1_desc,
    a.mkt_clsfn_cd2,
    a.mkt_clsfn2_desc,
    a.mkt_clsfn_cd3,
    a.mkt_clsfn3_desc,
    a.exp_sty_ind,
    a.silh_cd,
    a.silh_desc,
    a.whlsl_prc,
    0,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    a.gender_age_class_id,
    a.gender_age_desc,
    a.sports_activity_class_id,
    a.sports_act_cls_desc,
    a.gblcatsummcode,
    a.gblcatsummdesc,
    a.gblcatcorefocuscode,
    a.gblcatcorefocusdesc,
    a.segment,
    a.segmentname,
    a.l4l_fl,
    NET.DIVISION,
    NET.DIVISIONNAME,
    NET.SUBLABEL,
    NET.SUBLABELNAME,
    NET.DEVELOPMENTREGION,
    NULL,
    NULL,
    NULL,
    NET.globalsourceindicator,
    NET.CARRYOVERFLAG,
    a.zz_chng_tmst,
    a.zz_update_tmst,
    a.zz_insert_tmst
    FROM RPT_APRL_PRODUCT A,
    (SELECT
    APRL.DIVISION||APRL.PLAN_CTRY||APRL.MKT_TYP_ID||APRL.MATERIAL ; AS KEY_MATERIAL,
    B.DIVISION,
    B.DIVISIONNAME,
    B.SUBLABEL,
    B.SUBLABELNAME,
    B.DEVELOPMENTREGION,
    C.GLOBALSOURCEINDICATOR,
    D.CARRYOVERFLAG
    from RPT_APRL_PRODUCTAPRL,
    NSC_PROD_CIMG B,
    NSC_PROD_REG_CIMG C,
    NSC_PROD_REG_CYC_CIMG D
    where APRL.MATERIAL = B.MATERIAL_NBR AND
    APRL.MATERIAL = C.MATERIAL_NBR AND
    APRL.MATERIAL = D.MATERIAL_NBR AND
    C.REG_ID = D.REG_ID) NET
    WHERE A.KEY_MATERIAL = NET.KEY_MATERIAL(+)
    Thanks for help in advance.

    I have 4 tables and these are some sample data for
    RPT_APRL_PRODUCT - Key Field = KEY_MATERIAL (this is a combination of plan_ctry,division,mkt_typ_id and material)
    Sample data
    KEY_MATERIAL          PLAN_CTRY   DIVISION  MKT_TYP_ID              MATERIAL
    10PART1136353-010      PART          10              1                      136353-010
    10AMER1136353-010      AMER          10              1                      136353-010
    10USA1136353-010       USA           10              1                      136353-010
    10CANA1136353-010      CANA          10              1                      136353-010
    10PART1137508-050      PART          10              1                      137508-050
    10AMER1137508-050      AMER          10              1                      137508-050
    10CANA1137508-050      CANA          10              1                      137508-050
    10USA1137508-050       USA           10              1                      137508-050
    10PART1137617-050      PART          10              1                      137617-050
    10AMER1137617-050      AMER          10              1                       137617-050nsc_prod_reg_cimg - keys (material_nbr and reg_id)
    MATERIAL                REG_ID          GLOBALSOURCEINDICATOR
    136353-010      3                                     G
    136353-010      6                                     G
    136353-010      7                                    
    137508-050      3                                    
    137508-050      6                                     G
    137508-050      7                                    
    137508-050      46                                    G
    137617-050      3                                    
    137617-050      6                                    
    137617-050      46                                    nsc_prod_reg_cyc_cimg - key is material_nbr, cyc_id, reg_id and orgversion_id
    MATERIAL_NBR       CYC_ID                    orgversion_id                                reg_ID                CARRYOVERFLAG
    136353-010      101                             1                                          3                             Y       
    136353-010      101                              1                                          6                             Y      
    136353-010      101                               1                                          7                             N      
    137508-050      202                               1                                          3                             Y     
    137508-050      202                               1                                          6                             N       
    137508-050      202                               1                                          7                                    
    137617-050      205                               1                                          3                                    
    137617-050      205                               1                                          6                                    
    185204-402      181                              1                                          8                                    
    185204-402      182                               1                                          8                                     nsc_prod_cimg - key is material_nbr
    MATERIAL_NBR     SUBLABEL     SUBLABELNAME
    136353-010           
    137508-050                GD           Good
    137617-050
    185204-402
    185204-402
    185204-402                BE            Better
    185204-402
    185204-402
    185204-402               CO            Core
    185204-402               BS             BestWhat I intend to do, is to create one view by joining these four tables. The columns key_material, plan_ctry, division and MKT_TYP_ID come from RPT_APRL_PRODUCT. I need to join these tables in such a way that I bring in the other 1 or 2 columns each from the 3 tables as described above. The result should have a unique key_material and have the other column data in the view as well.
    Result should be all the columns described above, something like this below...
    KEY_MATERIAL          PLAN_CTRY   DIVISION  MKT_TYP_ID              MATERIAL      SUBLABELNAME  CARRYover_FL
    10PART1136353-010      PART          10              1                      136353-010
    10AMER1136353-010      AMER          10              1                      136353-010

  • Help with joining tables

    hello can some one help me in joining the tables
    po_vendors of AP and gl_je_headers or gl_he_headers of GL
    thankyou

    How about this:
    Build first an auxiliary table (you can truncate it every time) and in it:
    create table auxtab as
    select distinct employeeid, row_date from table1
    union
    select distinct employeeid, row_date from table2
    union
    select distinct employeeid, row_date from table3
    union
    Then you can use this "auxiliar" table as the driving one for outer joins
    select * from auxtab left outer join table1 on ()
    left outer join table2 on ()
    left outer join table3 on ()
    etc..

  • 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);

  • Help with the insert table/form tool in BIP 10.1.3.2.1

    Hi, I'm trying to use the insert table/form tool in BIP, and running into some issues that I don't understand. First off, my data coming in looks like this (left column of tool):
    Rowset
    --- Row
    ------ Customer ID
    ------ Customer Name
    ------ Customer City
    ------ Product
    ------ Amount Sold
    I would like the output to do the following:
    a) have one page per customer. Customer should be determined by customer ID, and has attributes of customer ID, customer Name, Customer City
    b) Show a table of all products and the total Amount Sold by product for that customer
    c) Give a "grand total" for the customer
    Can someone help with the steps needed to do this? I've tried several variations of the following without much luck:
    1) Added Rowset and all children to the "Template" pane
    2) Clicked on the "Row" group, and set Grouping = Customer ID, with a break of "New page per Element"
    3) Clicked on the newly created (from step 2) Cust ID group, and set it to group by Product
    4) Moved "amount sold" to be at same level as Product
    5) Moved all of the customer attributes (name, address, etc.) to be at same level as Cust ID
    6) On the Cust ID level, set the style to table
    7) on row and rowset levels, set style to free form
    This seems to be VERY close, except that it isn't creating a total amount for the sum of all products purchased by a customer. What do I need to do inside the tool to get a total per customer to show up?
    Thanks in advance!
    Scott
    p.s. the final hierarchy in the template window looks like this:
    Rowset (style = freeform, no grouping/sort by/breaks)
    --- Row (style = freeform, group by customer ID, break new page per element)
    ------ Customer ID (style = table, group by product, no breaks)
    --------- Product (nothing special)
    --------- Amount Sold (calc for grouping = SUM)
    ------ Customer Name (nothing special)
    ------ Customer City (nothing special)
    Thanks very much for the help!
    Scott

    To anyone else who sees this post, the answer is to do the following. Insert the Amount Sold field using the "Insert Field" tool, and set the function to sum, with the grouping checkbox turned on.
    Thanks,
    Scott

  • Newbie: help with join in a select query

    Hi: I need some help with creating a select statement.
    I have two tables t1 (fields: id, time, cost, t2id) and t2 (fields: id, time, cost). t2id from t1 is the primary key in t2. I want a single select statement to list all time and cost from both t1 and t2. I think I need to use join but can't seem to figure it out even after going through some tutorials.
    Thanks in advance.
    Ray

    t1 has following records
    pkid, time, cost,product
    1,123456,34,801
    2,123457,20,802
    3,345678,40,801
    t2 has the following records
    id,productid,time,cost
    1,801,4356789,12
    2,801,4356790,1
    3,802,9845679,100
    4,801,9345614,12
    I want a query that will print following from t1 (time and cost for records that have product=801)
    123456,34
    345678,40
    followed by following from t2 (time and cost for records that have productid=801)
    4356789,12
    4356790,1
    9345614,12
    Is this possible?
    Thanks
    ray

  • Need Help on Joining multiple tables in Golden Gate

    Hi,
    Can you please help me with some examples on joining multiple tables in Golden Gate. i.e, my requirement is to Join Table 1 & Table 2 in Source and Load it in Target with 10 fields from Table 1 & 5 fields from Table 2 based on the join condition between Table 1.key = Table2.key
    I have been trying to do that using SQLEXEC command in Golden Gate. But, is there a way I can do this in the Extract parameter file?
    Thanks for your time
    Regards
    Suresh

    Hi,
    Thanks a lot for the prompt reply. I am able to do that for the below scenario
    Source.T1.Field1
    Source.T1.Field2
    Source.T2.Field1
    Source.T2.Field2
    Target Table
    T1.Field1, T1.Field2, T2.Field1, T2.Field2.
    But, if I already have T2.Field1 in T1 table, then T1.Field1 takes the precendence and getting loaded. i.e., I wanted to join the table 1 & Table 2 and based on the matching condition, I will need to populate the data either from T1 or T2.
    Hope you got my requirement.
    Below the Data Dump file & Replicat File.
    EXTRACT dpump
    USERID ********, PASSWORD ********
    RMTHOST *******, MGRPORT 7809
    RMTTRAIL /oracle/gg/dirdat/rt
    --PASSTHRU
    TABLE TABLE1,
    SQLEXEC (ID LOOKUP,
    QUERY "SELECT FIELD1 FROM SOURCE.TABLE2 WHERE FIELD1 = :v_field1",
    PARAMS ( v_field1 = field1 )),
    TOKENS (tk_field_1 = @GETVAL (lookup.field1));
    Replicat file
    REPLICAT repjoin
    ASSUMETARGETDEFS
    HANDLECOLLISIONS
    USERID *******, PASSWORD ********
    MAP SOURCE.T1, TARGET TARGET.GG_TABLE_T1,
    COLMAP ( USEDEFAULTS ,
    field1 = @token ("tk_party_id"));
    I eventually wanted to join like below.
    select t1.field1, t1.field2, t2.field1 from t1, t2
    where t1.field1 = t2.field1;
    Thanks for your time again
    Regards
    Suresh

  • Prob with joins(5 tables)

    Hi All,
    I am facing problem to join 5 tables. it is giving more records. please help.
    TABLE 1 : Study
    Study_id     Study_name
    101        CFFFTY01TABLE 2: Study_site:
    study_id        site
    101              01
    101              02
    101              03Table 3 : Site_info
    Site        Country
    01          hyd
    02          chennai
    03          mumbaitable 4 : details
    study_id  error_id           open_date     closed_date
    101        abc01          01jan2013     05jan2013
    101     abc02          03jan2013     03jan2013
    101     abc03          05jan2013     06jan2013table 5 :error_details
    error_id      closed_by
    abc01      Murali
    abc02     geetha
    abc03         ramu--------------------------------------------------------------------------------------------------------------------------------------
    actullay main table is table 4 :
    I want output like below:
    study_name     site     country     error_id     open_date     closed_date     closed_by
    CFFFTY01     1     hyd     abc01     1-Jan-2013     5-Jan-2013     murali
    CFFFTY02     2     chennai     abc02     3-Jan-2013     3-Jan-2013     geetha
    CFFFTY03     3     mumbai     abc03     5-Jan-2013     6-Jan-2013     ramui tired but it is giving more than 3 records. plz help.
    Edited by: BluShadow on 21-Mar-2013 08:16
    added {noformat}{noformat} tags for readability.  Please read: {message:id=9360002} and learn to do this yourself in future.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    995263 wrote:
    Hi All,
    I am facing problem to join 5 tables. it is giving more records. please help.
    .. cut ..
    i tired but it is giving more than 3 records. plz help.You mean you are getting this?...
    SQL> with study as (select 101 as study_id, 'CFFFTY01' as study_name from dual)
      2      ,study_site as (select 101 as study_id, '01' as site from dual union all
      3                      select 101, '02' from dual union all
      4                      select 101, '03' from dual)
      5      ,site_info as (select '01' as site, 'Hyd' as country from dual union all
      6                     select '02', 'Chennai' from dual union all
      7                     select '03', 'Mumbai' from dual)
      8      ,details as (select 101 as study_id, 'abc01' as error_id,  date '2013-01-01' as open_date, date '2013-01-05' as closed_date from dual union all
      9                   select 101, 'abc02', date '2013-01-03', date '2013-01-03' from dual union all
    10                   select 101, 'abc03', date '2013-01-05', date '2013-01-06' from dual)
    11      ,error_details as (select 'abc01' as error_id, 'Murali' as closed_by from dual union all
    12                         select 'abc02', 'Geetha' from dual union all
    13                         select 'abc03', 'Ramu' from dual)
    14  --
    15  -- end of test data
    16  --
    17  select s.study_name
    18        ,ss.site
    19        ,si.country
    20        ,d.error_id
    21        ,d.open_date
    22        ,d.closed_date
    23        ,ed.closed_by
    24  from   details d
    25         join error_details ed on (d.error_id = ed.error_id)
    26         join study s on (s.study_id = d.study_id)
    27         join study_site ss on (ss.study_id = s.study_id)
    28         join site_info si on (si.site = ss.site)
    29  order by 1
    30  /
    STUDY_NA SI COUNTRY ERROR OPEN_DATE            CLOSED_DATE          CLOSED
    CFFFTY01 01 Hyd     abc03 05-JAN-2013 00:00:00 06-JAN-2013 00:00:00 Ramu
    CFFFTY01 01 Hyd     abc02 03-JAN-2013 00:00:00 03-JAN-2013 00:00:00 Geetha
    CFFFTY01 01 Hyd     abc01 01-JAN-2013 00:00:00 05-JAN-2013 00:00:00 Murali
    CFFFTY01 02 Chennai abc03 05-JAN-2013 00:00:00 06-JAN-2013 00:00:00 Ramu
    CFFFTY01 02 Chennai abc02 03-JAN-2013 00:00:00 03-JAN-2013 00:00:00 Geetha
    CFFFTY01 02 Chennai abc01 01-JAN-2013 00:00:00 05-JAN-2013 00:00:00 Murali
    CFFFTY01 03 Mumbai  abc03 05-JAN-2013 00:00:00 06-JAN-2013 00:00:00 Ramu
    CFFFTY01 03 Mumbai  abc02 03-JAN-2013 00:00:00 03-JAN-2013 00:00:00 Geetha
    CFFFTY01 03 Mumbai  abc01 01-JAN-2013 00:00:00 05-JAN-2013 00:00:00 Murali
    9 rows selected.
    SQL>That's because each details record has a study_id of 101 and the study sites have 3 record (01,02 and 03) for site_id 101. So each detail record get's shown with each of the study sites as there is no data to indicate which study site the detail record relates to (i.e. you are missing a relationship in your data)
    How are you expecting to get:
    study_name     site     country     error_id     open_date     closed_date     closed_by
    CFFFTY01     1     hyd     abc01     1-Jan-2013     5-Jan-2013     murali
    CFFFTY02     2     chennai     abc02     3-Jan-2013     3-Jan-2013     geetha
    CFFFTY03     3     mumbai     abc03     5-Jan-2013     6-Jan-2013     ramuwhen you do not have CFFFTY02 or CFFFTY03 in your data?
    Essentially the data you have provided does not meet the required output. Fix the data first.

  • Possible for POJO to have a set of children with only one table?

    I have a situation that I'd like to model with Hibernate, but I'm not sure how to proceed.
    I've got two objects: Filter and Criterion. Filter has a java.util.Set of Criterion children.
    I currently have a schema with two tables: FILTERS and CRITERIA. The FILTERS table has nothing more than a primary key. CRITERIA has a foreign key relationship with FILTERS. I have a FilterDAO that will query the FILTERS table and bring back a Filter object that will use the one-to-many, parent-child relationship between the two tables to populate the Set.
    A DBA here has pointed out that the FILTERS table is anemic - it has nothing more than a primary key. She suggested that I eliminate it and go directly against the CRITERIA table to populate that Set.
    I'm so used to thinking about these things in terms of primary/foreign key relationships that I'm not seeing how to accomplish this with Hibernate. Is it a mere <set> declaration that populates the child java.util.Set<Criterion>? The WHERE clause would have to include a filter type. Is that where the JOIN has to come? Is the two table schema absolutely necessary, or can I get away without it?
    Hibernate allows the object model to be more fine-grained than the schema. The classic example is a PERSON table that has address information it in. I can model this on the object side using Person and Address classes and ask Hibernate to fetch the Address state as a component. Is this the same situation as my Filter and Criterion?
    Sorry if I sound confused, or if the question rambles. I guess I don't understand Hibernate well, because any time I get off the beaten path I fall into a hole.
    %

    Well, you're more advanced than me with Hibernate. I'd be very surprised if that were true, DrClap. 8)
    I can't even get one-to-many relationships working the
    way I'd like, every time I think I have it right
    (i.e. just the same as the examples) it gives me some
    guff about backreferences not existing.I'm finding Hibernate to be a bit difficult, especially when I don't have control over the schema. Our DBAs don't seem to follow all the "best practices" that Hibernate recommends.
    So my advice might not be the best. But if you don't
    have the Filters table, but you still need to get all
    the Criterions with "filter key" = x, then isn't that
    just a Query? Sure, you get the data back as a List,
    but you can wrap that in a Set pretty easily.I've gone back to the DBA and concluded that we have to have a FILTERS table (there's a FILTER_TYPE descriptor field that I've added). It's back in, so the 1:m with CRITERIA should work fine.
    But it begs the question: Does Hibernate and O/R mapping demand at least one table per object?
    If I look in "Hibernate In Action" on page 92, it says "A major objective of the Hibernate project is support for fine grained object models" - more classes than tables. There should be an adjective "persistent" applied to classes in that phrase, because I can have many more classes that are not persisted.
    So I take this to mean that the limit is one persistent class per table, but never less. True?
    %

  • Performance issue with joins on table VBAK, VBEP, VBKD and VBAP

    hi all,
    i have a report where there is a join on all 4 tables VBAK, VBEP, VBKD and VBAP.
    the report is giving performance issues because of this join.
    all the key fields are used for the joining of tables. but some of the non-key fields like vbap-vstel, vbap-abgru and vbep-wadat are also part of select query and are getting filled.
    because of these there is a performance issue.
    is there any way i can improve the performance of the join select query?
    i am trying "for all entries" clause...
    kindly provide any alternative if possible.
    thanks.

    Hi,
    Pls perform some of the below steps as applicable for the performance improvement:
    a) Remove join on all the tables and put joins only on header and item (VBAK & VBAP).
    b) code should have separate select for VBEP and VBKD.
    c) remove the non key fields from the where clause. Once you retrieve data from the database into the internal table, sort the table and delete the entries which are not part of the non-key fields like vstel, abgru and wadat.
    d) last option is you can create index in the VBAP & VBEP table with respect to the fields vstel, abgru & wadat ( not advisable)
    e) buffering option on database tables also possible.
    f) select only the fields into the internal table that are applicable for the processing logic and also the select query should contaian the field names in the same order as mentioned in the database table.
    Hope this helps.
    Regards
    JLN

  • Does anybody know how to get help with this one?

    Hello there!  
    I wanted to get an advice on how to get in touch with the appropriate person at BT that could help with my situation.
    I have tried telephone help, complaints by email and unfortunately still waiting for somebody from the customer services to help me out.
    I have recently moved home.  I contacted BT on 26th June to organise the line transfer to the new address. The date was set for 18th July. I also ordered line rental saver and paid for it over the phone. All went smooth, telephone and broadband was working fine at the new place, but on the 23rd July I was sent an email that "BT is sorry that I am leaving". 
    I thought it was a mistake, but the lady in the on-line chat said somebody stopped my service. Later she rang and left a message saying that I must have requested to move to another provider. Did not manage to speak to her again, but phoned the help line this time.
    There a gentleman was trying to convince me that I called BT and cancelled my service on the 18th July and to him I was not a BT customer anymore. The truth is that I did not request to stop my service, anyway - why would I do that after paying for a year in advance. This has no logic, but because computer says so then he thinks I did it.
    He also added that my account is a 'mess'. He then promised that somebody would get in touch to sort it out as my line rental was gone and my phone and internet could go off any minute.
    I did not get any help. After that I wrote to them  3 email complaints to request assistance. They called and aknowledge they will help, but 3 weeks down the line nothing was done to explain the situation. Left the messages to the person from email complaints to ring me or email me -never happened.
    Last week I got 2 emails welcoming me to BT and outlining the call plans that were diferent from each other and the one I agreed to on the 25th June. When I called help line 2 days ago a lady confirmed on which one I am on, but could not sort out the most annoying thing - the 'final' bill. 
    I was sent a bill for over 200 pounds due to premature termination of phone and broadband service , which I never ordered. They already took the money this week. My line saver is gone as well. So I am 360 pounds short. I aslo have no access to myBT to monitor my phone activity or make orders.They also did not send any confrimation of the call plan I am currently on.
    It is a very annoying situation, because somebody at BT made an error and I am unable to get to anybody that could help. Everytime you call the help line you speak to somebody else and despite me thinking the email complaints would be the way forward they are not. Would appreciate some advice on how to tackle these issues: false accusations from them, inappropriate billing, problem with myBT.
    Thanks Lukasz

    Hi lbadek
    I can help with this please send us an email using the contact the mods link in my proifle and we will investigated from there.
    Thanks
    Stuart
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry that we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

Maybe you are looking for