JOIN Vs SELECT

Hi All,
I have  arequirement to improve the perofrmance of an extractor. It has to get data from two tables. Is it good to have a single JOIN to pickup all columns or better to have two separet SELECT staments. Currently the seacrh field (WHERE Clause) uses primary key but there is no index available on it. This SQL statement will come in my user exit. Please tell me which is a better option.
1. Create a single JOIN statment and make sure both columns in the WHERE has INDEX created on the search field.
2. Create two individual SELECT stament and have INDEX created on the WHERE clause on the search field.
I would like to go with Option 1. Is it better than Option 2?
Ideas welcome.
Alex(Arthur Samson)

Hi Alex,
I recommend option 1. You are however going to have indexes so, option 1 is better as you have just one hit to the database. In the second option, there will be 2 requests going to the database. So, some communication time can be saved.
Thanks and Regards
Subray Hegde

Similar Messages

  • Error joining the selected airport network?

    I'm trying to connect to my linksys wireless using WPA with a powerbook but no luck. My password which I know is correct (it's working on another G4 and my wife's Gateway. I get the following message when selected my network. "There was an error joining the selected airport network". I can connect via a neighbor's unprotected network, so airport is working. Other times I've tried it says password is incorrect.

    Wi-Fi Protected Access networks normally require a plain-text password or passphrase. But in rare cases you may have to enter a string of 64 delightful hexadecimal characters.
    The HEX password is derived from the plaintext password therefore you shouldn't need to create anything new. Check the linksys router for the HEX version of your plaintext password.
    The AirPort interface doesn't welcome this wonderful practice by default (imagine that), but it's buried in there for when you need it. Just hold down the Option key while choosing your network from the AirPort menu, then you'll be set to enter all 64 of those easy-to-remember characters.
    iFelix

  • Inner join and select for all entries with respect to performance

    Hi Friends,
    I just want to know which is more efficient with respect to performance the Inner join or select for all entries?which is more efficient? and how? can you explain me in detail ?
    Regards,
    Dinesh

    INNER JOIN->
    The data that can be selected with a view depends primarily on whether the view implements an inner join or an outer join. With an inner join, you only get the records of the cross-product for which there is an entry in all tables used in the view. With an outer join, records are also selected for which there is no entry in some of the tables used in the view.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ec77446011d189700000e8322d00/content.htm
    FOR ALL ENTRIES->
    Outer join can be created using this addition to the where clause in a select statement. It speeds up the performance tremendously, but the cons of using this variation are listed below
    Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.
    If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.
    If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.
    Not Recommended
    Loop at int_cntry.
    Select single * from zfligh into int_fligh
    where cntry = int_cntry-cntry.
    Append int_fligh.
    Endloop.
    Recommended
    Select * from zfligh appending table int_fligh
    For all entries in int_cntry
    Where cntry = int_cntry-cntry.

  • Default join in select statements

    Hi guyz,
    If I am using just Join in my select statement. What does it do by default
    1. innter join
    2. outer join
    eg:
    select vbeln posnr into table itab from vbak <b>join</b> vbap on vbakvbeln = vbapvbeln.
    Thanks.

    Mgs,
      By Default innerjoin.
    See the diff.
    Hi karan check also the "left outer join" statement.
    It might help you if you need 1-N relation
    // left outer Join
    Table 1                      Table 2
    A
    B
    C
    D
    D
    E
    F
    G
    H
    a1
    b1
    c1
    1
    1
    e1
    f1
    g1
    h1
    a2
    b2
    c2
    1
    3
    e2
    f2
    g2
    h2
    a3
    b3
    c3
    2
    4
    e3
    f3
    g3
    h3
    a4
    b4
    c4
    3
    |--|||--|
        Left Outer Join
        |--||||||||--|
        | A  | B  | C  | D  | D  | E  | F  | G  | H  |
        |--||||||||--|
        | a1 | b1 | c1 | 1  | 1  | e1 | f1 | g1 | h1 |
        | a2 | b2 | c2 | 1  | 1  | e1 | f1 | g1 | h1 |
        | a3 | b3 | c3 | 2  |NULL|NULL|NULL|NULL|NULL|
        | a4 | b4 | c4 | 3  | 3  | e2 | f2 | g2 | h2 |
        |--||||||||--|
    // Inner Join
    Table 1                      Table 2
    A
    B
    C
    D
    D
    E
    F
    G
    H
    a1
    b1
    c1
    1
    1
    e1
    f1
    g1
    h1
    a2
    b2
    c2
    1
    3
    e2
    f2
    g2
    h2
    a3
    b3
    c3
    2
    4
    e3
    f3
    g3
    h3
    a4
    b4
    c4
    3
        Inner Join
    A
    B
    C
    D
    D
    E
    F
    G
    H
    a1
    b1
    c1
    1
    1
    e1
    f1
    g1
    h1
    a2
    b2
    c2
    1
    1
    e1
    f1
    g1
    h1
    a4
    b4
    c4
    3
    3
    e2
    f2
    g2
    h2
    Pls. mark if useful

  • Inner join and select for all entries with respect to performance in SAP

    Hi Friends,
    I just want to know which is more efficient with respect to performance the Inner join or select for all entries?which is more efficient?
    Regards,
    Dinesh

    I did some testing a while ago and found that a JOIN is usually a bit more efficient than FOR ALL ENTRIES. This wasn't always the case though, so the best thing to do is to write it both ways and see which is faster.
    Rob

  • Pl sql join and selecting columns from join."t"."c": invalid at debug time

    I noticed the error at cc.Country that is shown because cc is not yet there at compile time (got that
    from searching this forum).
    Isnt that a bit weak of oracle sql developer that it doesnt compile from the outside to the inside /core but
    rather form top to bottom?
    Am I right with my conclusion? If so, how to do it otherwise i.e. specifying that cc.country is
    a column from countrycodes joined with table6 ?
    SELECT DISTINCT 0,
    2,
    SUBSTR('metable', 0, 1) || '_ABC',
    'ABC_' || 'metable',
    'ABC ' ||cc.Country ,
    '+'
    FROM table6
    LEFT JOIN COUNTRYCODE cc
    ON cc.Code = metable
    WHERE metable IS NOT NULL
    AND metable <> ''

    metalray wrote:
    hi Boneist
    thanks for your reply
    its in a plsql procedure (10g). well as you see cc is the alias
    of the table COUNTRYCODE. which does exists. the error is at 'ABC ' ||cc.Country'
    telling me"PL/SQL: ORA-01747: invalid user.table.column,..."
    when I put COUNTRYCODE next to table6 in the FROM it works but thats not what I want
    since I want to join both tables not just select from both.Can you give us your exact code and exact error message.
    I'm not finding any problem with using alias names in the query..
    SQL> select d.dname
      2        ,'EMPNAME : '||e.ename
      3  from dept d LEFT JOIN emp e ON e.deptno = d.deptno;
    DNAME          'EMPNAME:'||E.ENAME
    RESEARCH       EMPNAME : SMITH
    SALES          EMPNAME : ALLEN
    SALES          EMPNAME : WARD
    RESEARCH       EMPNAME : JONES
    SALES          EMPNAME : MARTIN
    SALES          EMPNAME : BLAKE
    ACCOUNTING     EMPNAME : CLARK
    RESEARCH       EMPNAME : SCOTT
    ACCOUNTING     EMPNAME : KING
    SALES          EMPNAME : TURNER
    RESEARCH       EMPNAME : ADAMS
    SALES          EMPNAME : JAMES
    RESEARCH       EMPNAME : FORD
    ACCOUNTING     EMPNAME : MILLER
    OPERATIONS     EMPNAME :
    15 rows selected.
    SQL>

  • Problem with JOINs in SELECT query

    The parameter  wa_dob-e_dob is not getting its definition ....
    it contains DOB in current yr.
    As i am using Joins also Workarea.... so is it coz Joins & WA cant be used simultaneously in a SELECT query....
    Is there any other option to do the same...?
    *  Global Structure
    TYPES : BEGIN OF t_data ,                     "Structure
            emp_dob TYPE pa0002-gbdat,
            emp_Mailid TYPE pa0105-usrid,
           END OF t_data,
           BEGIN OF t_dob,
           e_dob TYPE pa0002-gbdat,
           e_pernr type pa0002-pernr,
           END OF t_dob.
    *  Global Internal Tables (I_)
    DATA : i_data TYPE TABLE OF t_data,           "Internal Table for output data
           i_dob TYPE TABLE OF t_dob.             "Internal table for Dob
    *  Global Work Area (WA_)
    DATA : wa_data TYPE  t_data,                  "Work Area for output data
           wa_dob TYPE  t_dob.                    "Work Area for Dob
    *this is the query where i am getting error
    * Field "WA_DOB-E_DOB" Not found.
    LOOP AT i_dob INTO wa_dob.
        SELECT pa0002~gbdat pa0105~usrid INTO CORRESPONDING FIELDS OF wa_data
          FROM pa0002
          INNER JOIN pa0105
          ON pa0002~pernr = pa0105~pernr
          WHERE  pa0105~subty EQ 'MAIL' AND
         wa_dob-e_dob BETWEEN w_sysdate AND w_edit_sysdate.
        ENDSELECT.
        APPEND wa_data TO i_data.
        CLEAR wa_data.
        CLEAR wa_dob.
        CLEAR l_temp_dob.
      ENDLOOP.

    Hi,
    you are checking the work area in the SELECT. IN WHERE condition of the select u should specify fields in either of the tables pa0002 , pa0105 for data population.
    The select is on the database table and not on the work area.for checking the data in the work area do this way:
    loop at it_dob into wa_dob.
    if wa_dob-e_dob between the range u want (w_sysdate AND w_edit_sysdate)
    endif.
    endloop.
    ie: wa_dob-e_dob >w_sysdate AND wa_dob-e_dob < w_edit_sysdate or
        wa_dob-e_dob < w_sysdate AND wa_dob-e_dob  >  w_edit_sysdate
    watever ur requirement is..
    regards,
    madhu

  • How to replace Below Joins in select query ?

    SELECT ko~ebeln     ko~lifnr     a1~name1
             ko~bsart                   " Purchasing Document Type
             po~menge                   " PO quantity
             po~meins                   " PO Unit
             po~netpr                   " Net Price
             ko~kdate                   " End of validity period
             po~pstyp                   " Item category in PO
             po~wepos                   " Goods Receipt indicator
             ko~spras                   " Language Key
             ko~frggr                   " Release group
             ko~frgsx                   " Release strategy
             ko~frgke                   " Release Indicator
             po~matnr
             po~txz01
             po~ebelp
             po~werks
             po~lgort
             ko~waers
             ko~ernam
             ko~aedat
             po~netwr
             po~repos
        INTO TABLE itab_details
        FROM   ekko AS ko INNER JOIN ekpo AS po
                 ON ko~ebeln = po~ebeln
              INNER JOIN t161 AS t1
                 ON ko~bsart = t1~bsart
                AND ko~bstyp = t1~bstyp
              INNER JOIN lfa1 AS a1
                 ON ko~lifnr = a1~lifnr
       WHERE ko~ebeln IN s_ebeln
         AND po~loekz IN s_loekz
         AND po~werks IN s_werks
         AND po~lgort IN s_lgort
         AND ko~lifnr IN s_lifnr
         AND ko~bukrs IN s_bukrs
         AND t1~bsart IN s_bsart
         AND po~matnr IN s_matnr
         AND ko~ernam IN s_ernam
         AND ko~aedat IN s_aedat
         AND po~knttp IN s_knttp
         AND ko~ekgrp IN s_ekgrp
         AND po~pstyp IN s_pstyp.

    HI Amresh,
    Try like this.
    use inner join between Ekko and Ekpo.
    Then use for all entries for table  t161
    and finally  use for all entries for table  lfa1
    and use read in loop.
    Regards,
    Vijay

  • Fetch data from 3 tables (join vs select)

    hi all...
    i have to fetch data from three tables having one field common.
    should i go  with join or using three select statements..
    which one is better.. plz clarify..
    thanks in advance.
    regards.

    Hi,
    Use for all entries,  what are the tables...
    select field1
           field2
           from table
           into table itab.
    if sy-subrc = 0. "this is must ot table initial check
    select field2
           field3
           from table2
        for all entries in itab
           into table itab2
    where field2 = itab-field2.
    select field2
           field5
           from table3
         for all entries in itab
           into table itab3
    where field2 = itab-field2.
    endif.

  • What is syntax for inner join of Select statement with  Secondary Index

    Hi Genies,
                    Here i have created the Secondary index for table COEP and also used for select query but there is no improvement in runtime . taking same time for select query without index as well as with index. my code is
    SELECT *  INTO CORRESPONDING FIELDS OF TABLE ITAB_COEP FROM COEP AS A
                 INNER JOIN COBK  AS B ON ( A~BELNR = B~BELNR AND A~KOKRS = B~KOKRS AND A~GJAHR = B~GJAHR )
                 WHERE A~OBJNR = OBJNR
                 AND A~GJAHR = CURRY
                 AND B~GJAHR = CURRY
                 AND A~RBEST = ''
                 AND A~BEKNZ = 'S'
                 AND B~BELNR NE WA_COBK-BELNR
                 AND B~AWREF_REV = ''
                 AND B~AWORG_REV = ''
                 AND B~KOKRS = WA_COIOB-KOKRS
                 AND B~BLDAT BETWEEN START_DATE AND END_DATE
                 AND B~BLART IN ('SA','KA','KR','AB')  %_HINTS ORACLE 'INDEX("COEP" "COEP~ZBU")'.
    index name is ZBU.
    please any one let me know is there any syntax mistakes? but while checking and during the runtime it does'nt shows any error.
    Regards,
            Thangam.P

    Hi Genies,
                    Here i have created the Secondary index for table COEP and also used for select query but there is no improvement in runtime . taking same time for select query without index as well as with index. my code is
    SELECT *  INTO CORRESPONDING FIELDS OF TABLE ITAB_COEP FROM COEP AS A
                 INNER JOIN COBK  AS B ON ( A~BELNR = B~BELNR AND A~KOKRS = B~KOKRS AND A~GJAHR = B~GJAHR )
                 WHERE A~OBJNR = OBJNR
                 AND A~GJAHR = CURRY
                 AND B~GJAHR = CURRY
                 AND A~RBEST = ''
                 AND A~BEKNZ = 'S'
                 AND B~BELNR NE WA_COBK-BELNR
                 AND B~AWREF_REV = ''
                 AND B~AWORG_REV = ''
                 AND B~KOKRS = WA_COIOB-KOKRS
                 AND B~BLDAT BETWEEN START_DATE AND END_DATE
                 AND B~BLART IN ('SA','KA','KR','AB')  %_HINTS ORACLE 'INDEX("COEP" "COEP~ZBU")'.
    index name is ZBU.
    please any one let me know is there any syntax mistakes? but while checking and during the runtime it does'nt shows any error.
    Regards,
            Thangam.P

  • JOIN in select query

    Hi All,
    I need to do an enhancement in the following Select query.
    SELECT
    MARA data
                  a~matnr
    MARC data
                  b~werks
    MARA data
                 a~normt
                 a~ean11
                 a~labor
                 a~mstae
                 a~mstde
                 a~bismt
                 a~spart
                 a~zzsc
                 a~zzmc
                 a~zzpc
                 a~zzbu
                 a~zz4tpc
                 a~zz6tpc
                 a~kosch
                 a~iprkz
                 g~bmatn
                 a~normt
                 g~mfrnr
                 a~bstme
                 a~zeifo
                 a~ersda
    MARC data
                 b~mtvfp
                 b~sernp
                 b~herkl
                 b~ekgrp
                 b~dispo
                 b~insmk
                 b~disgr
                 b~ladgr
                 b~lgfsb
                 b~mtver
                 b~perkz
                 b~eprio
                 b~wzeit
    MVKE data
                 c~dwerk
                 c~kondm
                 c~bonus
                 c~mtpos
                 c~provg
                 c~mvgr1
                 c~mvgr2
                 c~mvgr3
                 c~prat9
                 c~prat1
    MBEW data
                 d~bklas
                 d~stprs
          INTO  TABLE i_materials
          FROM  ( marc as b
           inner jOIN mara AS a ON amatnr = bmatnr
           inner JOIN mvke AS c ON cmatnr = amatnr
           inner JOIN ampl AS g ON gbmatn = amatnr
          LEFT OUTER JOIN mbew AS d ON dmatnr = bmatnr
                                   AND dbwkey = bwerks )
         WHERE a~matnr  IN s_matnr
           AND a~normt  IN s_normt
           AND a~mstae  IN s_mstae
           AND a~zz4tpc IN s_zz4tpc
           AND a~zz6tpc IN s_zz6tpc
           AND a~bismt  IN s_bismt
           AND a~iprkz  IN s_iprkz
           AND a~spart  IN s_spart
           AND a~zzsc   IN s_zzsc
           AND a~zzpc   IN s_zzpc
           AND a~zzmc   IN s_zzmc
           AND a~zzbu   IN s_zzbu
           AND a~ersda  IN s_ersda
    MARC Data
           AND b~werks  IN s_werks
           AND b~ekgrp  IN s_ekgrp
           AND b~disgr  IN s_disgr
           AND b~perkz  IN s_perkz
           AND b~sernp  IN s_sernp
           AND b~ladgr  IN s_ladgr
           AND b~mtvfp  IN s_mtvfp
           AND b~lgfsb  IN s_lgfsb
           AND b~mtver  IN s_mtver
           AND b~eprio  IN s_eprio
           AND b~wzeit  IN s_wzeit
           AND b~herkl  IN s_herkl
    MVKE data
           AND c~mtpos  IN s_mtpos
           AND c~kondm  IN s_kondm
           AND c~bonus  IN s_bonus
           AND c~provg  IN s_provg
           AND c~mvgr1  IN s_mvgr1
           AND c~mvgr2  IN s_mvgr2
           AND c~mvgr3  IN s_mvgr3
    AMPL Data
           AND g~reoam <> 'X'.
    This query will pick the materials only if it is maintained across all the tables MARA,MARC,MVKE,AMPL,MBEW.
    Now the requirement is, the program should pick the materials that are maintained in MARA table, doesn't matter if the material is not maintained in the other tables.
    Please tell me how to modify this Select query. I dont have any idea on JOINs.
    Thanks in Advance,
    Neethu.

    Hi Manoj,
    I have modified the query like
    select fields
    FROM  ( mara as a
           left outer join marc AS b ON amatnr = bmatnr
           left outer Join mvke AS c ON amatnr = cmatnr
           left outer Join ampl AS g ON amatnr = gbmatn
           left outer Join mbew AS d ON amatnr = dmatnr )
        WHERE a~matnr  IN s_matnr
           AND a~normt  IN s_normt
           AND a~mstae  IN s_mstae
           AND a~zz4tpc IN s_zz4tpc
           AND a~zz6tpc IN s_zz6tpc
           AND a~bismt  IN s_bismt
           AND a~iprkz  IN s_iprkz
           AND a~spart  IN s_spart
           AND a~zzsc   IN s_zzsc
           AND a~zzpc   IN s_zzpc
           AND a~zzmc   IN s_zzmc
           AND a~zzbu   IN s_zzbu
           AND a~ersda  IN s_ersda
    MARC Data
           AND b~werks  IN s_werks
           AND b~ekgrp  IN s_ekgrp
           AND b~disgr  IN s_disgr
           AND b~perkz  IN s_perkz
           AND b~sernp  IN s_sernp
           AND b~ladgr  IN s_ladgr
           AND b~mtvfp  IN s_mtvfp
           AND b~lgfsb  IN s_lgfsb
           AND b~mtver  IN s_mtver
           AND b~eprio  IN s_eprio
           AND b~wzeit  IN s_wzeit
           AND b~herkl  IN s_herkl
    MVKE data
           AND c~mtpos  IN s_mtpos
           AND c~kondm  IN s_kondm
           AND c~bonus  IN s_bonus
           AND c~provg  IN s_provg
           AND c~mvgr1  IN s_mvgr1
           AND c~mvgr2  IN s_mvgr2
           AND c~mvgr3  IN s_mvgr3
    AMPL Data
           AND g~reoam <> 'X'.
    I am getting the error, "No fields from the right-hand table of a LEFT OUTER JOIN may appear in the WHERE condition:"B~WERKS".
    Now prob. is with  WHERE condition. If you know the solution please let me know.

  • Time taking for inner joins in select

    Hi all,
    I am using inner join on 3 tables  ( PLKO,PLPO,PLAS) for the materials,
    it is taking database time 20% and abap time 78 %  and when i am using FM CARO_ROUTING_READ
    database time 48% and abap 52%.
    i am in confusion which is th ebest method to use inner join or FM.
    when i am checking in the server for plant in the selection screen , it is running lot of time
    This is first time i am working on the performance issue.
    Can you please anbody help me how to solve this issue.
    Regards,
    Madhavi

    Percentages don't mean much, how does the overall runtime compare? Is there a problem at all?
    Since you already used SE30, go a step further and study the hit list sorted by net time descending, only look at the top few items.
    Also read this:
    Please Read before Posting in the Performance and Tuning Forum
    Thomas

  • Inner join in select statement

    hi,
    i am using select statement like
    SELECT ekkoebeln ekkobukrs ekkobstyp ekkobsart ekko~ernam
               ekkolifnr ekkozterm ekkozbd1t ekkozbd2t ekko~zbd3t
               ekkozbd1p ekkozbd2p ekkoekorg ekkoekgrp ekko~waers
               ekkowkurs ekkokufix ekkobedat ekkokdate
    Begin of Changes, RICEF : 293.
               ekkozzhedg ekkozzheda ekkozzpba ekkozzpbubu lfa1~vbund
    End of Changes, RICEF . 293.
             lfa1land1 lfa1name1
             ekpa~lifn2
             INTO CORRESPONDING FIELDS OF TABLE iekko
             FROM ekko
                  JOIN lfa1 ON lfa1lifnr = ekkolifnr
                  LEFT JOIN ekpa ON ekpaebeln = ekkoebeln AND
                                    ekpa~ebelp = '00000'    AND
                                    ekpa~parvw = 'RS'
             FOR ALL entries IN icooi
             WHERE ekko~ebeln = icooi-refbn
             AND   ekko~zzhedg IN s_zzhedg
             AND   ekko~zzheda IN s_zzheda.
    where in ekko table ,the fields zzhedg and zzheda are appended..but in the debugging mode i am unable to see this 2 field....in the output also....so how should i write my select query?

    Hi,
    Is your select statement returning sy-subrc 0. In debugging mode may be your fields may not be visible in the screen since your internal table has many fields, you have to press >> forward button to check the fields.
    Thanks & Regards,
    Navneeth K.

  • Change Large Join to Selects (URGENT)

    Hi,
    I need to change the following Join to a number of selects, since the Join isn't working as it should. Also, is "for all entries" obsolete or is it still relevant?
    Here is the last part of the join, since I cannot list all of the fields:
      INTO TABLE itab_data
      from viqmelst as b
      inner join viqmfe   as c on bqmnum = cqmnum
      inner join viqmaml  as a on bqmnum = aqmnum and
                                  cfenum = afenum
      inner join viqmur   as d on bqmnum = dqmnum and
                                  cfenum = dfenum
      inner join viqmsm   as e on bqmnum = eqmnum and
                                  cfenum = efenum
      inner join TJ02T    as f on bstat  = fistat
      WHERE a~qmnum in s_qmnum and
            a~qmdat in s_qmdat and
            a~qmart in s_QMART and
            a~matnr in s_matnr and
            b~stat  in s_stat and
            b~charg in s_charg and
            f~spras = 'EN'.
      sort itab_data by qmnum fenum.
      delete adjacent duplicates from itab_data.
    Thanks,
    John

    Hi John,
    The FOR ALL ENTIRES option is used to avoid the adverse impact on performence that the JOINS make..
    Code like this:
    SELECT xx yy zz...
    INTO itab1
    FROM tab1
    WHERE.. Condtions of select options.
    IF sy-subrc EQ 0
    AND itab1[] IS NOT INITIAL.
    SELECT aa bb cc
    INTO itab2
    FROM tab2
    FOR ALL ENTRIES IN tab1
    WHERE join codition with tab1
    AND select conditions on fields of tab2 if any.
    and so on for all other tables..
    Thanks and Best Regards,
    Vikas Bittera.
    **Points for useful answers**

  • To Join 9 Select Statements

    Hi All,
    I have 9 select Statements,i can combine these queries by 'UNION' to get the result....but the process will be tedious.
    Is there any other option to do the same in a easy way.
    Example :
    SELECT ecv.creation_date "Initiation Date",
    eceb.c_ext_attr1 "REPORTING PERSON",
    eceb.c_ext_attr2 INITIATOR,
    eceb.c_ext_attr3 "REPORTING PERSON TITLE",
    eceb.d_ext_attr2 "AWARE DATE",
    eceb.c_ext_attr4 TELEPHONE
    FROM eng_changes_v ecv,
    eng_changes_ext_b eceb
    WHERE ecv.change_id = eceb.change_id
    AND ecv.change_notice = 'COM-10034'
    AND attr_group_id = 266;
    UNION
    SELECT eceb.c_ext_attr2 TYPE,
    eceb.c_ext_attr3 INSTITUTION,
    eceb.c_ext_attr4 TERRITORY,
    eceb.c_ext_attr5 "CUSTOMER NAME",
    eceb.c_ext_attr6 TITLE,
    eceb.c_ext_attr7 ADDRESS,
    eceb.c_ext_attr8 "ADDRESS 2",
    eceb.c_ext_attr9 CITY,
    eceb.c_ext_attr10 STATE,
    eceb.n_ext_attr1 ZIP,
    eceb.c_ext_attr11 COUNTRY,
    eceb.c_ext_attr12 TELEPHONE,
    eceb.c_ext_attr13 FAX
    FROM eng_changes_v ecv,
    eng_changes_ext_b eceb
    WHERE ecv.change_id = eceb.change_id
    AND ecv.change_notice = 'COM-10034'
    AND attr_group_id = 267;
    In this fashion i have 9 select statements.
    Thanks in advance!
    Ramya

    Well, this is not the silly EAV model …
    but it does look as something that has been slightly abused on the dynamic/generic side.
    You certainly do not want to UNION … it wouldn’t make sense anyway.
    Think of your ATTR_GROUP_ID as identifiers of what could have been real tables
    (dependents of ENG_CHANGES_V):
    create view could_be_table_266 as
    select change_id
          ,c_ext_attr1  REPORTING_PERSON
          ,c_ext_attr2  INITIATOR
          ,c_ext_attr3  REPORTING_PERSON_TITLE
          ,d_ext_attr2  AWARE_DATE
          ,c_ext_attr4  TELEPHONE
    from   eng_changes_ext_b
    where  attr_group_id = 266
    create view could_be_table_267 as
    select change_id
          ,c_ext_attr2   TYPE
          ,c_ext_attr3   INSTITUTION
          ,c_ext_attr4   TERRITORY
          ,c_ext_attr5   CUSTOMER NAME
          ,c_ext_attr6   TITLE
          ,c_ext_attr7   ADDRESS
          ,c_ext_attr8   ADDRESS_2
          ,c_ext_attr9   CITY
          ,c_ext_attr10  STATE
          ,n_ext_attr1   ZIP
          ,c_ext_attr11  COUNTRY
          ,c_ext_attr12  TELEPHONE
          ,c_ext_attr13  FAX
    from   eng_changes_ext_b
    where  attr_group_id = 267
    Then join using your knowledge of what the “logical” relationship between these table would be … likely
    select <columns_you_need_from x>
          ,<columns_you_need_from a>
          ,<columns_you_need_from b>
    from   eng_changes_v       x
          ,could_be_table_266  a
          ,could_be_table_267  b
    where  x.change_id = a.change_id (+)
    and    x.change_id = b.change_id (+)
    and    x.change_notice = 'COM-10034'
    Using column names like "REPORTING PERSON" rather than REPORTING_PERSON is just a pain in the …
    What column headings one wants in a report/screen doesn’t have to drive the names of select list items in SQL.
    TYPE is likely not a good name … reserved word

Maybe you are looking for

  • Animated gif to be a Treenode image, can it?

    I would like to put the animated gif as a treenode image. But it doesn't show. Is there any way?

  • Trying to format and reinstall (lion download not working)

    Recently finder completely stopped working so i decided the best option was to just reinstall OSX lion, I didnt recieve an install disk but noticed there was an option to reinstall on the start up disk menu. I have erased all of my partitions and i a

  • How to enable New Schema in existing EUL

    Hi, We have a single EUL and recently, we have created a new schema. Could anyone direct me as to how I could see this schema listed down along with the rest of the schemas in my selection? Do I need to login as EUL_MANAGER and do a refresh? We have

  • Getting 500 internal server error when calling IIS application in portal

    Hello All, We have setup to access IIS application from portal http server. We have setup proxy rules in portal http server. When we are accessing the link of IIS,we are getting 500 internal server error. In the sso log file,we are getting the below

  • Calling another transaction in a new NWBC tab and keeping OBN

    Hiya, I have two reports (web dynpro reports) that I've created. Each report has buttons that are supoposed to open SAP transactions. So I've added code to the buttons that make the OBN calls, the reports have been added to the PFCG, and then OBN det