What is left join /right join / out join/ inner join/please give example!

what is left join /right join / out join/ inner join/please give example!
thanks

Maybe these examples will give you an idea...
SQL> select * from t1;
        ID
         1
         2
         3
         4
SQL> select * from t2;
        ID
         3
         4
         5
         6
-- LEFT OUTER JOIN
SQL> select t1.id, t2.id
  2  from t1 LEFT OUTER JOIN t2 ON (t1.id = t2.id);
        ID         ID
         3          3
         4          4
         1
         2
-- RIGHT OUTER JOIN
SQL> select t1.id, t2.id
  2  from t1 RIGHT OUTER JOIN t2 ON (t1.id = t2.id);
        ID         ID
         3          3
         4          4
                    6
                    5
-- LEFT JOIN (SAME AS LEFT OUTER JOIN)
SQL> ed
Wrote file afiedt.buf
  1  select t1.id, t2.id
  2* from t1 LEFT JOIN t2 ON (t1.id = t2.id)
SQL> /
        ID         ID
         3          3
         4          4
         1
         2
-- RIGHT JOIN (SAME AS RIGHT OUTER JOIN)
SQL> ed
Wrote file afiedt.buf
  1  select t1.id, t2.id
  2* from t1 RIGHT JOIN t2 ON (t1.id = t2.id)
SQL> /
        ID         ID
         3          3
         4          4
                    6
                    5
-- INNER JOIN (REGULAR JOIN)
SQL> ed
Wrote file afiedt.buf
  1  select t1.id, t2.id
  2* from t1 INNER JOIN t2 ON (t1.id = t2.id)
SQL> /
        ID         ID
         3          3
         4          4
-- FULL OUTER JOIN
SQL> ed
Wrote file afiedt.buf
  1  select t1.id, t2.id
  2* from t1 FULL OUTER JOIN t2 ON (t1.id = t2.id)
SQL> /
        ID         ID
         3          3
         4          4
         1
         2
                    6
                    5
6 rows selected.
SQL>

Similar Messages

  • How to  Join two tables using the Inner Join

    Hi All,
    I have two tables i.e table1 and table2 as i have created two otds and my present requirement is to join this two tables and get the results and using this i need to do some logic and update another table3.
    can some one help me out how to go for the above req.
    Thanks in Advance
    Srikanth

    The best efficient way to use inner join is create two input otds,use there otd's in create a collaboration usinf etl.
    after selecting two input otd's create a inner join statement and map it to out put otd.
    while using the etl the performance of the over all integration is increased 20 time of the normal integration.
    Hopes this will helps,,
    Thanks,
    Papa Rao.

  • Vertical spry menu bar 2.0 - orientation of submenus (left vs. right fly-out)

    Hello:
    I have a general question I would like to pose to anyone who has worked with the vertical spry 2.0 menu bar regarding the orientation of sub-menus (left vs. right flyout).  In the previous version of the spry menu bar it was possible to to designate that the flyout sub-menus would appear to the left (as opposed to the right (normal or standard position) of the main level menu bar.
    In reviewing the tutorials for the new version, and reviewing the settings for the widget I can't seem to see anything similar for the latest version of the spry menu bar.  Does anyone now if this is possible?  Does it require adjustments to the Javascript or can it be done directly from within the widget customization.
    I realize that it isn't normal practice to pose questions in such general terms, however I thought I would try to determine if anyone has had experience in this regard before launching into the project.
    Thanks in advance.
    Steve Webster

    OK, here's what I've done. By adjusting the right padding on #MenuBarVertical .MenuItem .MenuItemLabel, AND #MenuBarVertical .SubMenu .MenuItem .MenuItemLabel, I was able to position the right arrows to where I wanted them. I also removed all links from top-level menu items so that the fly-out submenus would appear on a touch screen. You can see the results on my client site: www.gcssepm.org. I must say that this solution was not intuitive; it took a lot of experimentation to figure out which rule to adjust, and menu rules vs. submenu rules seem to operate in the opposite manner as far as padding and arrows go.
    I do have a similar issue with Scott, in that it takes two or more "taps" to get the submenus to fly out, but at least the arrow is there so the user knows there is a submenu to be had. The only real issue I still have is that for sub-submenus (i.e., third-level), no amount of tapping will get those to display long enough to select them (only an issue on the iPad). I don't know a way around this for the iPad, other than to also eliminate all links from second-level menus that have a third level, and that's more reprogramming than I want to do for today.
    Final questions regarding the Spry 2.0 widget. Obviously, after I customized the widget, saved it, and imported into my site template, it took some additional tweaking before everything was working properly. Is there a way to export the settings back out to the widget, so that all the tweaking is there? Also, is there a way to save my menu text back to the widget, because it is obviously NOT Home, Entertainment, Music, etc.
    Thanks for all your help, and I hope someone else benefits from my experiences as well.
    Gail

  • Join on 3 tables using inner join.

    Hi friends can one one correct the below code and send me back.
    its showing some error.
    SELECT a~matnr
               a~werks
               b~maktx
               c~prctr
               c~bklas
               C~stprs
               c~peinh
              INTO TABLE it_detail
              FOR ALL ENTRIES IN itab
              FROM marc AS a INNER JOIN makt AS b
              ON amatnr = bmatnr
              inner join mbew AS c
              WHERE a~matnr = itab-matnr
              and     werks = itab-werks.

    Hi,
    Pls find the below piece of code.
         begin of it_detail occurs 0,
               matnr like mara-matnr,
               werks like marc-werks,
               prctr like marc-prctr,          
               maktx like makt-maktx,
               bklas like mbew-bklas,
               stprs like mbew-stprs,
               peinh like mbew-peinh,
         end   of it_detail.
    SELECT a~matnr
    a~werks
    a~prctr
    b~maktx
    c~bklas
    C~stprs
    c~peinh
    INTO TABLE it_detail
    FROM marc AS a INNER JOIN makt AS b
    ON amatnr = bmatnr
    inner join mbew AS c
    on amatnr = cmatnr
    FOR ALL ENTRIES IN itab
    WHERE a~matnr = itab-matnr
    and   a~werks = itab-werks.
    if it is not working, pls send me the error message that you are getting.
    Thanks,
    Sreeram.
    Edited by: Sreeram Prasad on Aug 19, 2008 5:07 PM
    Edited by: Sreeram Prasad on Aug 19, 2008 5:12 PM

  • Im unable to remove songs by swiping left from right or deleting the usage. help please?

    I updated my phone to ios7 a while back and manage to fix majority/most of the bugs. Now the music is messed up. i've already tried the swipe thing and deleting the usage and nothing has work. Some of the songs wont come off my phone and i dont know how else i could remove it. Help?

    my phone started playing a song randomly while it was tucked away in my bag and I was in a crowded elevator. It was very embarrassing.
    Yes, that Barry Manilow elevator music is a bit embarrassing (sorry, just couldn't resist that).
    Have you tried resetting your iPhone in iTunes and then restore just those items you want back?

  • Outer join/inner join

    I have 4 related tables and want to join them all but can't
    figure out how to do it. Here are the columns that need to join:
    Table 1: EventID, PromoterID
    Table 2: EventID, LeagueID
    Table 3: LeagueID
    Table 4: PromoterID
    I want to join like this:
    Table2.EventID *= Table1.EventID and
    Table2.PromoterID = Table4.PromoterID and
    Table2.LeagueID = Table3.LeagueID
    But I can't do an outer and inner join on the same table.
    Events can have multiple leagues related to it. If I use
    inner joins for everything, it turns out okay until you search for
    an event by League - if that happens and the event has more than
    one related league, the search results will only show the league
    searched by and not all the other related leagues. If you search by
    other info like month or year, all leagues related to a particular
    event show up in the search results for each event. When I try to
    do an outer join on table 2 based on eventid, I then get stuck
    trying to join table 2 and table 3.
    This is probably a simple problem but my brain is feeling too
    fried to figure it out - can anyone help? Thanks!!

    You can also pull in the eventids based on leagues if your
    SQL engine supports subqueries.
    where
    Table2.EventID = Table1.EventID and
    Table2.PromoterID = Table4.PromoterID and
    Table2.LeagueID = Table3.LeagueID
    <cfif isdefined("form.leagueid")>
    <cfif trim(form.leagueid) neq ''>
    and table2.eventid in
    (select t2a.eventid from table2 t2a
    where t2a.eventid = table2.eventid
    and t2a.leagueid = '#form.leagueid#')
    </cfif>
    </cfif>
    <cfif isdefined("form.eventid")>
    <cfif trim(form.eventid) neq ''>
    and table2.eventid = '#form.eventid#'
    </cfif>
    </cfif>
    <cfif isdefined("form.promoterid")>
    <cfif trim(form.promoterid) neq ''>
    and table2.prompterid = '#form.promoterid#'
    </cfif>
    </cfif>
    ...

  • Urgent: inner joins

    i wanna add inner joins in my report,plz give me d link of websites which provide suitable example.. if u r having example of it den do tell me...
    its really urgent...

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

  • Syntax of  inner join

    hello sir,
                 plz tell me the syntax of inner join for three tables.

    Syntax
    ... [(] {dbtab_left [AS tabalias_left]} | join
    {[INNER] JOIN}|{LEFT [OUTER] JOIN}
    {dbtab_right [AS tabalias_right] ON join_cond} [)] ... .
    Effect
    The join syntax represents a recursively nestable join expression. A join expression consists of a left-hand and a right- hand side, which are joined either by means of [INNER] JOIN or LEFT [OUTER] JOIN . Depending on the type of join, a join expression can be either an inner ( INNER) or an outer (LEFT OUTER) join. Every join expression can be enclosed in round brackets. If a join expression is used, the SELECT command circumvents SAP buffering.
    On the left-hand side, either a single database table, a view dbtab_left, or a join expression join can be specified. On the right-hand side, a single database table or a view dbtab_right as well as join conditions join_cond can be specified after ON. In this way, a maximum of 24 join expressions that join 25 database tables or views with each other can be specified after FROM.
    AS can be used to specify an alternative table name tabalias for each of the specified database table names or for every view. A database table or a view can occur multiple times within a join expression and, in this case, have various alternative names.
    The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after the addition WHERE, with the following differences:
    At least one comparison must be specified after ON.
    Individual comparisons may be joined using AND only.
    All comparisons must contain a column in the database table or the view dbtab_right on the right-hand side as an operand.
    The following language elements may not be used: BETWEEN, LIKE, IN.
    No sub-queries may be used.
    For outer joins, only equality comparisons (=, EQ) are possible.
    If an outer join occurs after FROM, the join condition of every join expression must contain at least one comparison between columns on the left-hand and the right-hand side.
    In outer joins, all comparisons that contain columns as operands in the database table or the view dbtab_right on the right-hand side must be specified in the corresponding join condition. In the WHERE condition of the same SELECT command, these columns are not allowed as operands.
    Resulting set for inner join
    The inner join joins the columns of every selected line on the left- hand side with the columns of all lines on the right-hand side that jointly fulfil the join_cond condition. A line in the resulting set is created for every such line on the right-hand side. The content of the column on the left-hand side may be duplicated in this case. If none of the lines on the right-hand side fulfils the join_cond condition, no line is created in the resulting set.
    Resulting set for outer join
    The outer join basically creates the same resulting set as the inner join, with the difference that at least one line is created in the resulting set for every selected line on the left-hand side, even if no line on the right-hand side fulfils the join_cond condition. The columns on the right-hand side that do not fulfil the join_cond condition are filled with null values.
    Example
    Join the columns carrname, connid, fldate of the database tables scarr, spfli and sflight by means of two inner joins. A list is created of the flights from p_cityfr to p_cityto. Alternative names are used for every table.
    PARAMETERS: p_cityfr TYPE spfli-cityfrom,
    p_cityto TYPE spfli-cityto.
    DATA: BEGIN OF wa,
    fldate TYPE sflight-fldate,
    carrname TYPE scarr-carrname,
    connid TYPE spfli-connid,
    END OF wa.
    DATA itab LIKE SORTED TABLE OF wa
    WITH UNIQUE KEY fldate carrname connid.
    SELECT ccarrname pconnid f~fldate
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM ( ( scarr AS c
    INNER JOIN spfli AS p ON pcarrid = ccarrid
    AND p~cityfrom = p_cityfr
    AND p~cityto = p_cityto )
    INNER JOIN sflight AS f ON fcarrid = pcarrid
    AND fconnid = pconnid ).
    LOOP AT itab INTO wa.
    WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.
    Example
    Join the columns carrid, carrname and connid of the database tables scarr and spfli using an outer join. The column connid is set to the null value for all flights that do not fly from p_cityfr. This null value is then converted to the appropriate initial value when it is transferred to the assigned data object. The LOOP returns all airlines that do not fly from p_cityfr.
    PARAMETERS p_cityfr TYPE spfli-cityfrom.
    DATA: BEGIN OF wa,
    carrid TYPE scarr-carrid,
    carrname TYPE scarr-carrname,
    connid TYPE spfli-connid,
    END OF wa,
    itab LIKE SORTED TABLE OF wa
    WITH NON-UNIQUE KEY carrid.
    SELECT scarrid scarrname p~connid
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM scarr AS s
    LEFT OUTER JOIN spfli AS p ON scarrid = pcarrid
    AND p~cityfrom = p_cityfr.
    LOOP AT itab INTO wa.
    IF wa-connid = '0000'.
    WRITE: / wa-carrid, wa-carrname.
    ENDIF.
    ENDLOOP.
    we r using 2 type of joins in abap they are
    1) inner join.
    this will join 2 tables using an common fiend and return the result with field values wich are common in both the tables
    itab1 itab2
    a b c a d
    1 2 3 1 5
    2 3 4 3 6
    after innerjoining itab1 n itab2 on field a we wil get the o/p as
    a b c d
    1 2 3 5
    only common field is taken..
    2)left outer join
    here it wil work in opossite way it will give values whic are not common
    itab1 itab2
    a b c a d
    1 2 3 1 5
    2 3 4 3 6
    after left outer joining itab1 n itab2 on field a we wil get the o/p as
    a b c d
    2 3 4
    only fields which are not common is taken from the left table..other field(d here) wil be empty
    I think it will help u.
    Reward Points if helpful.
    Check for ALVROBOT.COM also it is also helpful.

  • Inner join command

    Hi Forum,
    How to use Inner join command?
    Please explain with an example.
    Thanks,
    Mahathi

    Inner Join and Outer 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.
    The set of hits determined by an inner join can therefore be a subset of the hits determined with an outer join.
    Database views implement an inner join. The database therefore only provides those records for which there is an entry in all the tables used in the view. Help views and maintenance views, however, implement an outer join.
    Specifying Database Tables
    The FROM clause determines the database tables from which the data specified in the SELECT clause is read. You can specify either a single table or more than one table, linked using inner or outer joins. The names of database tables may be specified statically or dynamically, and you can use alias names. You can also use the FROM clause to bypass the SAP buffer and restrict the number of lines to be read from the database.
    "Database table" can equally mean an ABAP Dictionary view. A view links two or more database tables in the ABAP Dictionary, providing a static join that is available systemwide. You can specify the name of a view wherever the name of a database table may occur in the FROM clause.
    The FROM clause has two parts - one for specifying database tables, and one for other additions:
    SELECT... FROM <tables> <options>...
    In <tables>, you specify the names of database tables and define joins. <options> allows you to specify further additions that control the database access.
    Specifying Database Tables Statically
    To specify the name of a database table statically, use the following:
    SELECT... FROM <dbtab> [AS <alias>] <options> . ..
    The database table <dbtab> must exist in the ABAP Dictionary. The AS addition allows you to specify an alternative name <alias> that you can then use in the SELECT; FROM, WHERE, and GROUP BY clauses. This can eliminate ambiguity when you use more than one database table, especially when you use a single database table more than once in a join. Once you have defined an alias, you may no longer use the real name of the database table
    Specifying Database Tables Dynamically
    To specify the name of a database table dynamically, use the following:
    SELECT... FROM (<name>) <options> . ..
    The field <name> must contain the name of a database table in the ABAP Dictionary. The table name must be written in uppercase. When you specify the name of a database table dynamically, you cannot use an empty INTO clause to read all of the columns into the work area <dbtab>. It is also not possible to use alternative table names.
    Specifying Two or More Database Tables as an Inner Join
    In a relational database, you normally need to read data simultaneously from more than one database table into an application program. You can read from more than one table in a single SELECT statement, such that the data in the tables all has to meet the same conditions, using the following join expression:
    SELECT...
      FROM <tab> [INNER] JOIN <dbtab> [AS <alias>] ON <cond> <options>
    where <dbtab> is a single database table and <tab> is either a table or another join expression. The database tables can be specified statically or dynamically as described above. You may also use aliases. You can enclose each join expression in parentheses. The INNER addition is optional.
    A join expression links each line of <tab> with the lines in <dbtab> that meet the condition <cond>. This means that there is always one or more lines from the right-hand table that is linked to each line from the left-hand table by the join. If <dbtab> does not contain any lines that meet the condition <cond>, the line from <tab> is not included in the selection.
    The syntax of the <cond> condition is like that of the WHERE clause, although individual comparisons can only be linked using AND. Furthermore, each comparison must contain a column from the right-hand table <dbtab>. It does not matter on which side of the comparison it occurs. For the column names in the comparison, you can use the same names that occur in the SELECT clause, to differentiate columns from different database tables that have the same names.
    The comparisons in the condition <cond> can appear in the WHERE clause instead of the ON clause, since both clauses are applied equally to the temporary table containing all of the lines resulting from the join. However, each join must contain at least one comparison in the condition <cond>.
    Specifying Two or More Database Tables as a Left Outer Join
    In an inner join, a line from the left-hand database table or join is only included in the selection if there is one or more lines in the right-hand database table that meet the ON condition <cond>. The left outer join, on the other hand, reads lines from the left-hand database table or join even if there is no corresponding line in the right-hand table.
    SELECT...
      FROM <tab> LEFT [OUTER] JOIN <dbtab> [AS <alias>] ON <cond>
           <options>
    <tab> and <dbtab> are subject to the same rules and conditions as in an inner join. The OUTER addition is optional. The tables are linked in the same way as the inner join with the one exception that all lines selected from <tab> are included in the final selection. If <dbtab> does not contain any lines that meet the condition <cond>, the system includes a single line in the selection whose columns from <dbtab> are filled with null values.
    In the left outer join, more restrictions apply to the condition <cond> than in the inner join. In addition to the above restrictions:
    EQ or = is the only permitted relational operator.
    There must be at least one comparison between columns from <tab> and <dbtab>.
    The WHERE clause may not contain any comparisons with columns from <dbtab>. All comparisons using columns from <dbtab> must appear in the condition <cond>.
    Client Handling
    As already mentioned, you can switch off the automatic client handling in Open SQL statements using a special addition. In the SELECT statement, the addition comes after the options in the FROM clause:
    SELECT... FROM <tables> CLIENT SPECIFIED. ..
    If you use this addition, you can then address the client fields in the individual clauses of the SELECT statement.
    Disabling Data Buffering
    If buffering is allowed for a table in the ABAP Dictionary, the SELECT statement always reads the data from the buffer in the database interface of the current application server. To read data directly from the database table instead of from the buffer, use the following:
    SELECT... FROM <tables> BYPASSING BUFFER. ..
    This addition guarantees that the data you read is the most up to date. However, as a rule, only data that does not change frequently should be buffered, and using the buffer where appropriate improves performance. You should therefore only use this option where really necessary.
    Restricting the Number of Lines
    To restrict the absolute number of lines included in the selection, use the following:
    SELECT... FROM <tables> UP TO <n> ROWS. ..
    If <n> is a positive integer, the system reads a maximum of <n> lines. If <n> is zero, the system reads all lines that meet the selection criteria. If you use the ORDER BY clause as well, the system reads all lines belonging to the selection, sorts them, and then places the first <n> lines in the selection set.
    Examples
    Specifying a database table statically:
    REPORT demo_select_static_database.
    DATA wa TYPE scarr.
    SELECT *
      INTO wa
      FROM scarr UP TO 4 ROWS.
      WRITE: / wa-carrid, wa-carrname.
    ENDSELECT.
    The output is:
    The system reads four lines from the database table SCARR.
    Specifying a database table dynamically:
    REPORT demo_select_dynamic_database.
    DATA wa TYPE scarr.
    DATA name(10) TYPE c VALUE 'SCARR'.
    SELECT  *
      INTO  wa
      FROM  (name) CLIENT SPECIFIED
      WHERE mandt = '000'.
      WRITE: / wa-carrid, wa-carrname.
    ENDSELECT.
    A condition for the MANDT field is allowed, since the example uses the CLIENT SPECIFIED option. If NAME had contained the value ‘scarr’ instead of ‘SCARR’, a runtime error would have occurred.
    Inner join:
    REPORT demo_select_inner_join.
    DATA: BEGIN OF wa,
            carrid TYPE spfli-carrid,
            connid TYPE spfli-connid,
            fldate TYPE sflight-fldate,
            bookid TYPE sbook-bookid,
          END OF wa,
          itab LIKE SORTED TABLE OF wa
                    WITH UNIQUE KEY carrid connid fldate bookid.
    SELECT  pcarrid pconnid ffldate bbookid
      INTO  CORRESPONDING FIELDS OF TABLE itab
      FROM  ( ( spfli AS p
                INNER JOIN sflight AS f ON pcarrid = fcarrid AND
                                           pconnid = fconnid    )
                INNER JOIN sbook   AS b ON bcarrid = fcarrid AND
                                           bconnid = fconnid AND
                                           bfldate = ffldate     )
      WHERE p~cityfrom = 'FRANKFURT' AND
            p~cityto   = 'NEW YORK'  AND
            fseatsmax > fseatsocc.
    LOOP AT itab INTO wa.
      AT NEW fldate.
        WRITE: / wa-carrid, wa-connid, wa-fldate.
    ENDAT.
      WRITE / wa-bookid.
    ENDLOOP.
    This example links the columns CARRID, CONNID, FLDATE, and BOOKID of the table SPFLI, SFLIGHT, and SBOOK, and creates a list of booking numbers for all flights from Frankfurt to New York that are not fully booked. An alias name is assigned to each table.
    Left outer join:
    REPORT demo_select_left_outer_join.
    DATA: BEGIN OF wa,
            carrid   TYPE scarr-carrid,
            carrname TYPE scarr-carrname,
            connid   TYPE spfli-connid,
          END OF wa,
          itab LIKE SORTED TABLE OF wa
                    WITH NON-UNIQUE KEY carrid.
    SELECT scarrid scarrname p~connid
      INTO CORRESPONDING FIELDS OF TABLE itab
      FROM scarr AS s
           LEFT OUTER JOIN spfli AS p ON scarrid   =  pcarrid AND
                                         p~cityfrom = 'FRANKFURT'.
    LOOP AT itab INTO wa.
      WRITE: / wa-carrid, wa-carrname, wa-connid.
    ENDLOOP.
    The output might look like this:
    The example links the columns CARRID, CARRNAME, and CONNID of the tables SCARR and SPFLI using the condition in the left outer join that the airline must fly from Frankfurt. All other airlines have a null value in the CONNID column in the selection.
    If the left outer join is replaced with an inner join, the list looks like this:
    Only lines that fulfill the ON condition are included in the selection.

  • Reply to vj (qery on the inner joins v/s performane test)

    this is ravi shiva's friend.
    hi vj,
             u r working for intelli group....and i had met u twice. by the way give u r contact number i want to speak to u personally.
              here is the code... 
    REPORT  rv_sid_purchase_order_status NO STANDARD PAGE HEADING MESSAGE-ID zrv_message_cl LINE-COUNT 65 LINE-SIZE 110 .
    This include contains declarations
    INCLUDE zrv_sid_purchase_order_t.
    This include contains code for the performs
    INCLUDE zrv_sid_purchase_order_f.
                          Initialization
    INITIALIZATION.
    This perform will initialize the values.
      PERFORM f_initilaize.
    This perform will initialize the field catalog.
      PERFORM f_e01_fieldcat_init USING gt_fieldcat[].
                         Start-Of-Selection
    START-OF-SELECTION.
    This perform will read the values from the database.
      PERFORM f_selection.
    This perform will call the function module to display the values on the list.
      PERFORM f_display.
              End-Of-Selection
    END-OF-SELECTION.
    *&  Include           ZRV_SID_PURCHASE_ORDER_T                         *
               T a b l e s   D e c l a r a t i o n s                     *
    TABLES: ekko,ekpo,ekbe,ekkn,mkpf.
               Type Pools  D e c l a r a t i o n s                       *
    TYPE-POOLS: slis.
          Selection Screen Declaration
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-100.
    SELECT-OPTIONS: ebeln FOR ekko-ebeln,
                    aedat FOR ekko-aedat.
    SELECTION-SCREEN END OF BLOCK b1.
               V a r i  a b l e s                                        *
    DATA : gt_fieldcat         TYPE  slis_t_fieldcat_alv,
           g_repid             LIKE  sy-repid,
           gs_keyinfo          TYPE  slis_keyinfo_alv,
           g_tabname_header    TYPE  slis_tabname,
           g_tabname_item      TYPE  slis_tabname,
           ls_layout           TYPE  slis_layout_alv,
           gt_list_top_of_page TYPE  slis_t_listheader.
               I n t e r n a l  T a b l e s                               *
    DATA: BEGIN OF itab OCCURS 0,
           ebeln LIKE ekko-ebeln,
           lifnr LIKE ekko-lifnr,
           aedat LIKE ekko-aedat,
           submi LIKE ekko-submi,
           name1 LIKE lfa1-name1,
           netwr LIKE erev-netwr,
          END OF itab.
    DATA: BEGIN OF jtab OCCURS 0,
           ebeln      LIKE  ekpo-ebeln,
           ebelp      LIKE  ekpo-ebelp,
           aedat      LIKE  ekpo-aedat,
           txz01      LIKE  ekpo-txz01,
           menge1     LIKE  ekpo-menge,
           menge2     LIKE  ekbe-menge,
           effwr1     LIKE  ekpo-effwr,
           mwskz1     LIKE  ekpo-mwskz,
           ps_psp_pnr LIKE  ekkn-ps_psp_pnr,
           bewtp1     LIKE  ekbe-bewtp,
           belnr1     LIKE  ekbe-belnr,
           dmbtt      LIKE  ekbe-dmbtr,
           mblnr1     LIKE  mkpf-mblnr,
           bldat1     LIKE  mkpf-bldat,
           xblnr1     LIKE  mkpf-xblnr,
           frbnr      LIKE  mkpf-frbnr,
          END OF jtab.
    *&  Include           ZRV_SID_PURCHASE_ORDER_F                         *
    FORM f_initilaize .
      g_repid = sy-repid.
      g_tabname_header            = 'itab'.
      g_tabname_item              = 'jtab'.
      CLEAR gs_keyinfo.
      gs_keyinfo-header01         = 'EBELN'.
      gs_keyinfo-item01           = 'EBELN'.
      gs_keyinfo-header02         = space.
      gs_keyinfo-item02           = 'EBELP'.
      ls_layout-group_change_edit = 'X'.
      ls_layout-colwidth_optimize = 'X'.
      ls_layout-zebra             = 'X'.
      ls_layout-detail_popup      = 'X'.
      ls_layout-get_selinfos      = 'X'.
      ls_layout-window_titlebar   = 'PURCHASE ORDER STATUS'.
      ls_layout-no_keyfix         = 'X'.
    ENDFORM.                    " f_INITILAIZE
    *&      Form  f_e01_fieldcat_init
          text
         -->E01_LT_FIELtext
    FORM f_e01_fieldcat_init  USING  e01_lt_fieldcat TYPE slis_t_fieldcat_alv.
      DATA: ls_fieldcat TYPE slis_fieldcat_alv.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'SUBMI'.
      ls_fieldcat-tabname       = g_tabname_header.
      ls_fieldcat-ref_fieldname = 'SUBMI'.
      ls_fieldcat-ref_tabname   = 'EKKO'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'EBELN'.
      ls_fieldcat-tabname       = g_tabname_header.
      ls_fieldcat-ref_fieldname = 'EBELN'.
      ls_fieldcat-ref_tabname   = 'EKPO'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'LIFNR'.
      ls_fieldcat-tabname       = g_tabname_header.
      ls_fieldcat-ref_fieldname = 'LIFNR'.
      ls_fieldcat-ref_tabname   = 'EKKO'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'NAME1'.
      ls_fieldcat-tabname       = g_tabname_header.
      ls_fieldcat-ref_fieldname = 'NAME1'.
      ls_fieldcat-ref_tabname   = 'LFA1'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'NETWR'.
      ls_fieldcat-tabname       = g_tabname_header.
      ls_fieldcat-ref_fieldname = 'NETWR'.
      ls_fieldcat-ref_tabname   = 'EREV'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-do_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'EBELP'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-ref_fieldname = 'EBELP'.
      ls_fieldcat-ref_tabname   = 'EKPO'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'TXZ01'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-ref_fieldname = 'TXZ01'.
      ls_fieldcat-ref_tabname   = 'EKPO'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-just = 'L'.
      ls_fieldcat-fieldname     = 'MWSKZ1'.
      ls_fieldcat-seltext_l     = 'Tax code'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-ref_fieldname = 'MWSKZ1'.
      ls_fieldcat-ref_tabname   = 'EKPO'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-just          = 'L'.
      ls_fieldcat-fieldname     = 'PS_PSP_PNR'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-ref_fieldname = 'PS_PSP_PNR'.
      ls_fieldcat-ref_tabname   = 'EKKN'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'MENGE1'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-seltext_l     = 'Po quantity'.
      ls_fieldcat-ref_fieldname = 'MENGE1'.
      ls_fieldcat-ref_tabname   = 'EKPO'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'MENGE1'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'EFFWR1'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-seltext_l     = 'Po value'.
      ls_fieldcat-ref_fieldname = 'EFFWR1'.
      ls_fieldcat-ref_tabname   = 'EKPO'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'BEWTP1'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-seltext_l     = 'Cat'.
      ls_fieldcat-ref_fieldname = 'BEWTP1'.
      ls_fieldcat-ref_tabname   = 'EKBE'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'BELNR1'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-seltext_l     = 'GR/IR MDoc'.
      ls_fieldcat-ref_fieldname = 'BELNR1'.
      ls_fieldcat-ref_tabname   = 'EKBE'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'MENGE2'.
      ls_fieldcat-seltext_l     = 'GR/IR quantity'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-ref_fieldname = 'MENGE2'.
      ls_fieldcat-ref_tabname   = 'EKBE'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'MBLNR1'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-seltext_l     = 'GR No'.
      ls_fieldcat-ref_fieldname = 'MBLNR1'.
      ls_fieldcat-ref_tabname   = 'MKPF'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'BLDAT1'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-seltext_l     = 'GR Date'.
      ls_fieldcat-ref_fieldname = 'BLDAT1'.
      ls_fieldcat-ref_tabname   = 'MKPF'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'FRBNR'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-ref_fieldname = 'FRBNR'.
      ls_fieldcat-ref_tabname   = 'MKPF'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'XBLNR1'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-seltext_l     = 'Invoice No in GR'.
      ls_fieldcat-ref_fieldname = 'XBLNR1'.
      ls_fieldcat-ref_tabname   = 'MKPF'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
      CLEAR ls_fieldcat.
      ls_fieldcat-fieldname     = 'DMBTT'.
      ls_fieldcat-seltext_l     = 'Invoice value W/O tax'.
      ls_fieldcat-tabname       = g_tabname_item.
      ls_fieldcat-ref_fieldname = 'DMBTT'.
      ls_fieldcat-ref_tabname   = 'EKBE'.
      ls_fieldcat-key           = 'X'.
      ls_fieldcat-no_out        = 'X'.
      ls_fieldcat-no_sum        = 'X'.
      ls_fieldcat-sp_group      = 'A'.
      APPEND ls_fieldcat TO e01_lt_fieldcat.
    ENDFORM.                    " f_e01_fieldcat_init
    *&      Form  f_selection
          text
    FORM f_selection .
      SELECT   ekko~ebeln
               ekko~lifnr
               ekko~aedat
               ekko~submi
               lfa1~name1
               erev~netwr
                               FROM ekko  INNER JOIN lfa1 ON ( ekkolifnr = lfa1lifnr )
                                          INNER JOIN erev ON ( ekkoebeln = erevedokn )
                                          INTO TABLE itab WHERE ekko~ebeln IN ebeln AND
                                                                ekko~aedat IN aedat AND
                                                                bsart <> 'AN'.
      SELECT
             ekpo~ebeln
             ekpo~ebelp
             ekpo~aedat
             ekpo~txz01
             ekpo~menge
             ekbe~menge
             ekpo~effwr
             ekpo~mwskz
             ekkn~ps_psp_pnr
             ekbe~bewtp
             ekbe~belnr
             ekbe~dmbtr
             mkpf~mblnr
             mkpf~bldat
             mkpf~xblnr
             mkpf~frbnr
                            FROM  ekpo INNER JOIN ekkn      ON ( ekpoebeln = ekknebeln
                                                                           AND
                                                                 ekknebelp = ekpoebelp )
                                       INNER JOIN ekbe      ON ( ekknebeln = ekbeebeln
                                                                           AND
                                                                 ekknebelp = ekbeebelp )
                                       LEFT OUTER JOIN mkpf ON ( ekbebelnr = mkpfmblnr )
                                       INTO TABLE jtab FOR ALL ENTRIES IN itab WHERE ekpo~ebeln = itab-ebeln AND
                                                                                    ekpo~aedat = itab-aedat.
    ENDFORM.                    " f_selection
    *&      Form  f_display
          text
    FORM f_display .
      CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
        EXPORTING
          i_callback_program = g_repid
          it_fieldcat        = gt_fieldcat[]
          i_tabname_header   = g_tabname_header
          i_tabname_item     = g_tabname_item
          is_keyinfo         = gs_keyinfo
          is_layout          = ls_layout
        TABLES
          t_outtab_header    = itab
          t_outtab_item      = jtab.
    ENDFORM.                    " f_display

    Hi Ravi,
    1. To check performance of a report we use the perfromance trace. The transaction code is ST05.
    You can also refer the link :
         http://help.sap.com/saphelp_erp2005/helpdata/en/8a/3b834014d26f1de10000000a1550b0/content.htm
    2.  Also we can do the run time analysis of the code uising transaction code SE30.
    3. To do a general check on the code , you can use the SAP Code Inspector. The transaction code for this is SCI. This will defentely give you a detailed analysis of the program.
    4 . To have a general idea about the performance tuning of a report , you should refer the link :
       http://www.sapgenie.com/abap/performance.htm.
    Hope this solves yopur query.
    Regards,
    Kunal.

  • Doubt in Inner Join.

    Hi all,
    In a report program i have used a inner join. I am getting error in the where condition. Here I have furnished part of my code for ur reference.
    Tables : mara, makt, mard.
    data : begin of itab occurs 0,
    matnr like mara-matnr,
    maktx like makt-maktx,
    lgort like mard-lgort,
    labst like mard-labst,
    end of itab.
    parameters : matnr like mara-matnr.
    start-of-selection.
    select maramatnr maktmaktx mardlgort mardlabst into corresponding fields of iab from mara inner join maktx on maramatnr = maktmatnr inner join mard on maktmatnr = mardmatnr where matnr eq matnr.
    in the where condition I am getting the following error message.
    matnr has two meanings in data dictionary.
    Please help me in sort out this problem and also tell me more abt inner joins.
    thanks.

    HI,
    You can achieve this in two ways:
    1st:
    into corresponding fields of TABLE itab
    2nd:
    if you have inner join you don't need where any more at all! you already have connections.
    if you still need then use:
    tablename~fieldname
    for both sides!
    if in your example matnr from left side is local or global variable then you have problem with some naming conventions which usually are used in SAP.
    try 1st points at the beggining
    i'd write your select in this style
    Code:
             select mara~matnr
              makt~maktx
              mardlgort mardlabst
    into corresponding fields of table itab
    from ( mara
    inner join makt on maktmatnr = maramatnr
                   and makt~spras = sy-langu )
    inner join mard on mardmatnr = maramatnr.
    OR
        Code:
              select mara~matnr
              makt~maktx
              mardlgort mardlabst
    into corresponding fields of table itab
    from ( mara
    inner join makt on maktmatnr = maramatnr )
    inner join mard on mardmatnr = maramatnr
    where
            makt~spras = sy-langu.
    Cheers,
    Chandra Sekhar.

  • Inner join -select options

    Hi all,
    I have a query, but it doesn't work when i give select-options range table in WHERE clause.
    SELECT-OPTIONS  :
            l_bukrs  FOR  WA_INPUT-bukrs NO INTERVALS ,
      SELECT
                VBAK~BUKRS_VF AS BUKRS   "COMPANY CODE
                PA0001~ENAME     "SALES EMPLOYEE NAME
                KNA1~NAME1       "CLIENT
                VBKD~BSTKD       "PO NO
                VBAK~VBELN       "SO NO
                VBAK~AUDAT       "SO DATE
                VBAP~POSNR       "LINE
                VBAP~KWMENG      "QTY
                VBAP~VRKME       "UNIT
                VBAP~NETPR       "RATE
                VBAP~NETWR       "ORDER VALUE
                VBAP~WAERK       "DOCUEMNT CURRENCY
                VBAP~MATNR       "MATERIAL NO
                VBAP~ARKTX       "MATERIAL NAME
                VBKD~KURSK       "EXCHANGE RATE
                    INTO CORRESPONDING FIELDS OF TABLE IT_OPSALES
                      FROM  VBAP
                                LEFT OUTER JOIN  VBPA ON VBPAVBELN = VBAPVBELN AND VBPA~PARVW = 'AF'
                                INNER JOIN PA0001 ON PA0001PERNR = VBPAPERNR
                                INNER JOIN VBAK ON VBAKVBELN  = VBAPVBELN
                                INNER JOIN KNA1 ON KNA1KUNNR  = VBAKKUNNR
                                INNER JOIN VBKD ON VBKDVBELN = VBAKVBELN AND VBKDPOSNR = VBAPPOSNR
                      WHERE  BUKRS  IN L_BUKRS
    it wont support when i give L_bukrs in inner join clause..!!
    any idea to change the query??
    thaks and regards
    Jose

    Hi,
    Declare the select option as  s_bukrs .
    SELECT-OPTIONS :
    S_bukrs FOR WA_INPUT-bukrs NO INTERVALS ,
    SELECT
    VBAK~BUKRS_VF AS BUKRS "COMPANY CODE
    PA0001~ENAME "SALES EMPLOYEE NAME
    KNA1~NAME1 "CLIENT
    VBKD~BSTKD "PO NO
    VBAK~VBELN "SO NO
    VBAK~AUDAT "SO DATE
    VBAP~POSNR "LINE
    VBAP~KWMENG "QTY
    VBAP~VRKME "UNIT
    VBAP~NETPR "RATE
    VBAP~NETWR "ORDER VALUE
    VBAP~WAERK "DOCUEMNT CURRENCY
    VBAP~MATNR "MATERIAL NO
    VBAP~ARKTX "MATERIAL NAME
    VBKD~KURSK "EXCHANGE RATE
    INTO CORRESPONDING FIELDS OF TABLE IT_OPSALES
    FROM VBAP
    LEFT OUTER JOIN VBPA ON VBPAVBELN = VBAPVBELN AND VBPA~PARVW = 'AF'
    INNER JOIN PA0001 ON PA0001PERNR = VBPAPERNR
    INNER JOIN VBAK ON VBAKVBELN = VBAPVBELN
    INNER JOIN KNA1 ON KNA1KUNNR = VBAKKUNNR
    INNER JOIN VBKD ON VBKDVBELN = VBAKVBELN AND VBKDPOSNR = VBAPPOSNR
    WHERE BUKRS IN S_BUKRS
    Hope this helps you.
    Thanks & Regards,
    Y.R.Prem Kumar

  • Multiple inner join ..how they work ?

    Here is an example of INNER JOIN.
    SELECT whatever
      FROM tablea AS a
    INNER
      JOIN tableb AS b
        ON b.b = a.a
    INNER
      JOIN tablec AS c
        ON c.c = b.b1
    INNER
      JOIN tabled AS d
        ON d.d = c.c1As you see there are 3 inner join in a single query ...I'm uncomfortable with this ....because I dont know what is the order of execution of multiple inner joins .
    which inner join will be executed first and which is next and which is last ?

    Hi,
    user575089 wrote:
    but you know my concern is .... is not the result of inner join is fed to the next inner join ? ( because there is multiple inner join )Sorry, I don't know what your concern is. Try to explain it, prefereably with a concrete example. Post a specific query, using the dept, emp and salgrade tables in the scott schema (or 3 tables for which you post CREATE TABLE and INSERT statements), and a specific question about that query. If you really need 4 tables to show what your problem is, you can use the hr schama instead of scott.Is it possible to test using MySQL ? What happens when you try it?
    I know its an oracle forum You're right; this is an Oracle forum.
    ....that should not be a problem I guess... ..coz SQL is a universal language ...The English language spoken in Britain is different from the English language spoken in the United States. The differences are minor compared to, say, the differences between either and Hindi, but there are differences.
    The SQL langauge used in Oracle is different from the SQL language used in MySQL, even more that the English language used in Britain is different from the English language used in the United States.
    I'm guessing that how MySQL and Oracle perform inner joins is pretty similar, as far as it matters for your question, but that's just a guess. I don't know a lot about MySQL, and I don't know what your question is.

  • Inner joins on the tables VAKPA , VBAP and KNA1

    HI ,
    I have one performance issue.please see the below select query..In order to improve the performance i need to change this select query with out changing the functionality.Can any one of you please suggest me .
       SELECT vakpakunde vakpaparvw kna1kunnr kna1name1 kna1~ktokd
               vbapvbeln vbapposnr vbaparktx vbapzzclass
               vbapmvgr2 vbapmvgr3 vbapmvgr5 vbapzzcanvas_year
               vbapmatnr vbapmatkl
         FROM  vakpa
         INNER JOIN  vbap ON
               vakpavbeln = vbapvbeln
         INNER JOIN kna1 ON
               vakpakunnr = kna1kunnr
         INTO CORRESPONDING FIELDS OF TABLE gt_vbap
         WHERE vakpa~kunde IN so_kunnr
         AND   vakpa~parvw = 'AG'
         AND   vakpa~vkorg IN so_vkorg
         AND ( vbap~zzad_line_status = 'PR' OR
               vbap~zzad_line_status = 'RE' )
         AND   vbap~mvgr5         IN r_ctf
         AND   vbap~matkl         IN so_matkl
         AND   vbap~matnr         IN so_matnr
         AND   vbap~zzcanvas_year IN so_year.
      ENDIF.

    Use FOR ALL ENTRIES statement instead of joints.
    or
    and Remove INTO CORRESPONDING FIELDS by selecting the fields in the orderstored in table
    Edited by: kalandar on Dec 4, 2009 7:43 AM

  • Reports - Inner Joins

    Dear Friends,
    I need to prepare a classic report based on the following parameters :
    I would like to know, how to join these three tables using Inner Joins - MARA, MARC, MSTA.
    I should be able to view the fields from these tables.
    I tried out with the common fields from these tables, viz. MARA - MATNR - MARC, MARC - WERKS - MSTA.
    I would appreciate, if anyone replies me with the select statement using the above mentioned tables using Inner Joins statement with any common fields .
    Thanking you in anticipation.

    Dear dinesh kumar
    1. We can join the three tables with matnr field.
    2. WERKS has to be provided from the program - (plant).
       ie. For which plant, data is required.
    3. Due to MSTA table, you may get multiple records
       for same MATNR. bcos of maintenance records
       by different departments in MSTA Table.
    If it helps, pls give points.
    REPORT abc.
    data : begin of itab occurs 0,
           matnr like mara-matnr,
           "---- Other Fields
           end of itab.
    data : matnr like mara-matnr.
    data : werks like marc-werks.
    Query
    select a~matnr
    into table itab
    from mara  as a
    inner join marc as b
    on amatnr = bmatnr
    inner join msta as c
    on amatnr = cmatnr
    Required Conditions From Program
    where a~matnr = matnr
    and b~werks = werks.
    Thanks & Regards,
    Amit Mittal.

Maybe you are looking for