Help on Inner Join Query

Hi ABAPers,
I was trying to develop a report for which query is something like this.
*& Report  ZT_SERIAL
REPORT  ZT_SERIAL.
TABLES : SER01,SER03,OBJK,LIKP,LIPS. " LIKP - SD invoice header table, LIPS - SD invoice details table
TYPE-POOLS: SLIS.
DATA: AFIELD TYPE SLIS_FIELDCAT_ALV.
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
MANDATORY WHILE DECLARING ALV ***
DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV..
DATA: V_EVENTS TYPE SLIS_T_EVENT.
DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: P_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV.
DATA: I_TITLE_SL_NO_TRACK TYPE LVC_TITLE VALUE 'SERIAL NO TRACKER'.
DATA : BEGIN OF ITAB OCCURS 0,
       OBKNR LIKE OBJK-OBKNR,     "OBJECT LIST
       OBZAE LIKE OBJK-OBZAE,     "OBJECT COUNTER
       KUNDE LIKE SER01-KUNDE,    "CUSTOMER NO
       MATNR LIKE OBJK-MATNR,     "PART NO
       SERNR LIKE OBJK-SERNR,     "SERIAL NO
       MBLNR LIKE SER03-MBLNR,    "GRN/MATERIAL DOC NO
       LIEF_NR LIKE SER01-LIEF_NR,"OUTBOUND DELV NO
       DATUM LIKE SER01-DATUM,    "OUTBOUND DELV DATE
       TASER LIKE OBJK-TASER,     "HEADER TABLE
       ANZSN LIKE SER01-ANZSN,    "NO OF SERIAL NOS
       VGBEL LIKE LIPS-VGBEL,     "SALES ORDER NO
       END OF ITAB.
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_KUNDE FOR SER01-KUNDE,
                  S_VGBEL FOR LIPS-VGBEL,
                  S_MATNR FOR OBJK-MATNR,
                  S_SERNR FOR OBJK-SERNR,
                  S_MBLNR FOR SER03-MBLNR,
                  S_LIFNR FOR SER01-LIEF_NR,
                  S_DATUM FOR SER01-DATUM.
SELECTION-SCREEN : END OF BLOCK B1.
PERFORM TRACKING.
PERFORM FLDCAT.
PERFORM BUILD_LAYOUT.
***CALL FUNCTION TO DISPLAY IN ALV FORMAT*******
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    I_GRID_TITLE       = I_TITLE_SL_NO_TRACK
    IS_LAYOUT          = LAYOUT
    IT_FIELDCAT        = P_FIELDTAB[]
    I_SAVE             = 'A'
    IT_EVENTS          = V_EVENTS
  TABLES
    T_OUTTAB           = ITAB.
***END OF CALL FUNCTION
FORM TRACKING.
SELECT OBJKOBKNR OBJKOBZAE OBJKMATNR OBJKSERNR OBJK~TASER
       SER01KUNDE SER01LIEF_NR SER01DATUM SER01ANZSN
       SER03~MBLNR
       LIPS~VGBEL
       INTO TABLE ITAB FROM OBJK
       INNER JOIN SER01 ON OBJKOBKNR = SER01OBKNR
       INNER JOIN SER03 ON OBJKOBKNR = SER03OBKNR
       INNER JOIN LIPS ON SER01LIEF_NR = LIPSVBELN
       WHERE
       OBJKTASER = 'SER01' OR OBJKTASER = 'SER03'.
       OBJK~MATNR IN S_MATNR AND
       OBJK~SERNR IN S_SERNR AND
       SER01~KUNDE IN S_KUNDE AND
       SER01~LIEF_NR IN S_LIFNR AND
       SER01~DATUM IN S_DATUM AND
       SER03~MBLNR IN S_MBLNR AND
       LIPS~VGBEL IN S_VGBEL.
ENDFORM.
*&      Form  fldcat
      text
FORM FLDCAT.
  PERFORM FLDCAT1 USING 'KUNDE' 'Customer No'.
  PERFORM FLDCAT1 USING 'VGBEL' 'Sales Order No'.
  PERFORM FLDCAT1 USING 'MATNR' 'Tejas Part No'.
  PERFORM FLDCAT1 USING 'SERNR' 'Serial No'.
  PERFORM FLDCAT1 USING 'MBLNR' 'Material Doc No'.
  PERFORM FLDCAT1 USING 'LIEF_NR' 'Outbound Delv No'.
  PERFORM FLDCAT1 USING 'DATUM' 'Outbound Delv Date'.
ENDFORM.                    "fldcat
*&      Form  fldcat1
      text
     -->FNAM       text
     -->FTEXT      text
FORM FLDCAT1 USING FNAM FTEXT.
    DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
          L_FIELDCAT-FIELDNAME  = FNAM.
          L_FIELDCAT-SELTEXT_M = FTEXT.
  IF FNAM EQ 'MATNR'."OR fnam EQ 'PKUNAG'.
    L_FIELDCAT-KEY = 'X'.
  ENDIF.
  LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
  APPEND L_FIELDCAT TO P_FIELDTAB.
CLEAR fldcat1.
ENDFORM.                                                    "fldcat1
*&      Form  build_layout
      text
FORM BUILD_LAYOUT .
  LAYOUT-NO_INPUT          = 'X'.
  LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
  LAYOUT-ZEBRA = 'X'.
  LAYOUT-TOTALS_TEXT       = 'Totals'(256).
layout-coltab_fieldname = 'CELL_COLOUR'.
*clear layout.
ENDFORM.                   
But when I run this query,the program gets terminated.Can you please help me in rectifying the query and generate the output?
Thanks in advance
Bhavin

Hi
I have corrected the code please copy and past it and then try.
Report ZT_SERIAL.
TABLES : SER01,SER03,OBJK,LIKP,LIPS.
" LIKP - SD invoice header table, LIPS - SD invoice details table
TYPE-POOLS: SLIS.
DATA: AFIELD TYPE SLIS_FIELDCAT_ALV.
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
     + MANDATORY WHILE DECLARING ALV ***
DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV..
DATA: V_EVENTS TYPE SLIS_T_EVENT.
DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: P_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV.
DATA: I_TITLE_SL_NO_TRACK TYPE LVC_TITLE VALUE 'SERIAL NO TRACKER'.
DATA : BEGIN OF ITAB OCCURS 0,
OBKNR LIKE OBJK-OBKNR, "OBJECT LIST
OBZAE LIKE OBJK-OBZAE, "OBJECT COUNTER
KUNDE LIKE SER01-KUNDE, "CUSTOMER NO
MATNR LIKE OBJK-MATNR, "PART NO
SERNR LIKE OBJK-SERNR, "SERIAL NO
MBLNR LIKE SER03-MBLNR, "GRN/MATERIAL DOC NO
LIEF_NR LIKE SER01-LIEF_NR,"OUTBOUND DELV NO
DATUM LIKE SER01-DATUM, "OUTBOUND DELV DATE
TASER LIKE OBJK-TASER, "HEADER TABLE
ANZSN LIKE SER01-ANZSN, "NO OF SERIAL NOS
VGBEL LIKE LIPS-VGBEL, "SALES ORDER NO
END OF ITAB.
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_KUNDE FOR SER01-KUNDE,
S_VGBEL FOR LIPS-VGBEL,
S_MATNR FOR OBJK-MATNR,
S_SERNR FOR OBJK-SERNR,
S_MBLNR FOR SER03-MBLNR,
S_LIFNR FOR SER01-LIEF_NR,
S_DATUM FOR SER01-DATUM.
SELECTION-SCREEN : END OF BLOCK B1.
PERFORM TRACKING.
PERFORM FLDCAT.
PERFORM BUILD_LAYOUT.
***CALL FUNCTION TO DISPLAY IN ALV FORMAT*******
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_GRID_TITLE = I_TITLE_SL_NO_TRACK
IS_LAYOUT = LAYOUT
IT_FIELDCAT = P_FIELDTAB[]
I_SAVE = 'A'
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = ITAB.
***END OF CALL FUNCTION
FORM TRACKING.
*SELECT OBJK~OBKNR
      OBJK~OBZAE
      OBJK~MATNR
      OBJK~SERNR
      OBJK~TASER
      SER01~KUNDE
      SER01~LIEF_NR
      SER01~DATUM
      SER01~ANZSN
      SER03~MBLNR
      LIPS~VGBEL
  INTO TABLE ITAB FROM OBJK
  INNER JOIN  SER01 ON OBJKOBKNR = SER01OBKNR
  INNER JOIN  SER03 ON OBJKOBKNR = SER03OBKNR
  INNER JOIN  LIPS ON SER01LIEF_NR = LIPSVBELN
  WHERE
*( OBJKTASER = 'SER01' OR OBJKTASER = 'SER03' ) and
*OBJK-MATNR IN S_MATNR AND
*OBJK~SERNR IN S_SERNR AND
*SER01~KUNDE IN S_KUNDE AND
*SER01~LIEF_NR IN S_LIFNR AND
*SER01~DATUM IN S_DATUM AND
*SER03~MBLNR IN S_MBLNR AND
*LIPS~VGBEL IN S_VGBEL.
SELECT a~OBKNR         "OBJK
       a~OBZAE
       a~MATNR
       a~SERNR
       a~TASER
       b~KUNDE         "SER01
       b~LIEF_NR
       b~DATUM
       b~ANZSN
       c~MBLNR        "SER03
       D~VGBEL        "LIPS
   INTO TABLE ITAB FROM  ( OBJK as a
   INNER JOIN  SER01 as b ON aOBKNR = bOBKNR
   INNER JOIN  SER03 as c ON aOBKNR = cOBKNR
   INNER JOIN  LIPS as  d ON bLIEF_NR = dVBELN )
   WHERE
( aTASER = 'SER01' OR aTASER = 'SER03' ) and
a~MATNR IN S_MATNR AND
a~SERNR IN S_SERNR AND
b~KUNDE IN S_KUNDE AND
b~LIEF_NR IN S_LIFNR AND
b~DATUM IN S_DATUM AND
c~MBLNR IN S_MBLNR AND
d~VGBEL IN S_VGBEL.
ENDFORM.
*& Form fldcat
   * text
FORM FLDCAT.
PERFORM FLDCAT1 USING 'KUNDE' 'Customer No'.
PERFORM FLDCAT1 USING 'VGBEL' 'Sales Order No'.
PERFORM FLDCAT1 USING 'MATNR' 'Tejas Part No'.
PERFORM FLDCAT1 USING 'SERNR' 'Serial No'.
PERFORM FLDCAT1 USING 'MBLNR' 'Material Doc No'.
PERFORM FLDCAT1 USING 'LIEF_NR' 'Outbound Delv No'.
PERFORM FLDCAT1 USING 'DATUM' 'Outbound Delv Date'.
ENDFORM. "fldcat
*& Form fldcat1
    text
    -->FNAM text
    -->FTEXT text
FORM FLDCAT1 USING FNAM FTEXT.
DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
L_FIELDCAT-FIELDNAME = FNAM.
L_FIELDCAT-SELTEXT_M = FTEXT.
IF FNAM EQ 'MATNR'."OR fnam EQ 'PKUNAG'.
L_FIELDCAT-KEY = 'X'.
ENDIF.
LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
APPEND L_FIELDCAT TO P_FIELDTAB.
   * CLEAR fldcat1.
ENDFORM. "fldcat1
*& Form build_layout
   * text
FORM BUILD_LAYOUT .
LAYOUT-NO_INPUT = 'X'.
LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
LAYOUT-ZEBRA = 'X'.
LAYOUT-TOTALS_TEXT = 'Totals'(256).
   * layout-coltab_fieldname = 'CELL_COLOUR'.
*clear layout.
ENDFORM.
Regards,
Venkat

Similar Messages

  • Help with Inner Join query in SQL

    Hope someone can help with this, as this is quite an involved project for me, and I'm just about there with it.
    My table structure is :
    table_packages
    packageID
    package
    packageDetails
    etc
    table_destinations
    destinationID
    destination
    destinationDetails
    etc
    table_packagedestinations
    packageID
    destinationID
    ..so nothing that complicated.
    So the idea is that I can have a package details page which shows the details of the package, along any destinations linked to that package via the packagedestinations table.
    So this is the last part really - to get the page to display the destinations, but I'm missing something along the way....
    This is the PHP from the header, including my INNER JOIN query....
    PHP Code:
    <?php
    $ParampackageID_WADApackages = "-1";
    if (isset($_GET['packageID'])) {
      $ParampackageID_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
    $ParamSessionpackageID_WADApackages = "-1";
    if (isset($_SESSION['WADA_Insert_packages'])) {
      $ParamSessionpackageID_WADApackages = (get_magic_quotes_gpc()) ? $_SESSION['WADA_Insert_packages'] : addslashes($_SESSION['WADA_Insert_packages']);
    $ParampackageID2_WADApackages = "-1";
    if (isset($_GET['packageID'])) {
      $ParampackageID2_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
    mysql_select_db($database_connPackages, $connPackages);
    $query_WADApackages = sprintf("SELECT packageID, package, costperpax, duration, baselocation, category, dateadded, agerange, hotel, educational_tours, field_trips, corporate_outings, plant_visits, budget_package, rollingtours, teambuilding, description, offer FROM packages WHERE packageID = %s OR ( -1= %s AND packageID= %s)", GetSQLValueString($ParampackageID_WADApackages, "int"),GetSQLValueString($ParampackageID2_WADApackages, "int"),GetSQLValueString($ParamSessionpackageID_WADApackages, "int"));
    $WADApackages = mysql_query($query_WADApackages, $connPackages) or die(mysql_error());
    $row_WADApackages = mysql_fetch_assoc($WADApackages);
    $totalRows_WADApackages = mysql_num_rows($WADApackages);
    $colname_educationalDestinations = "1";
    if (isset($_GET['PackageID'])) {
      $colname_educationalDestinations = (get_magic_quotes_gpc()) ? packageID : addslashes(packageID);
    mysql_select_db($database_connPackages, $connPackages);
    $query_educationalDestinations = sprintf("SELECT * FROM destinations INNER JOIN (packages INNER JOIN packagedestinations ON packages.packageID = packagedestinations.packageID) ON destinations.destinationID = packagedestinations.destinationID WHERE packages.packageID = %s ORDER BY destination ASC", GetSQLValueString($colname_educationalDestinations, "int"));
    $educationalDestinations = mysql_query($query_educationalDestinations, $connPackages) or die(mysql_error());
    $row_educationalDestinations = mysql_fetch_assoc($educationalDestinations);
    $totalRows_educationalDestinations = mysql_num_rows($educationalDestinations);
    ?>
    And where I'm trying to display the destinations themselves, I have : 
    <table>
            <tr>
                     <td>Destinations :</td>
                </tr>
               <?php do { ?>
            <tr>
                 <td><?php echo $row_educationalDestinations['destination']; ?></td>
            </tr>
            <?php } while ($row_educationalDestinations = mysql_fetch_assoc($educationalDestinations)); ?>
    </table>
    If anyone could have a quick look and help me out that would be much appreciated - not sure if its my SQL at the top, or the PHP in the page, but either way it would be good to get it working. 
    Thanks.

    First off, you need to get the database tables so that there is a relationship between them.
    In fact, if there is a one to one relationship, then it may be better to store all of your information in one table such as
    table_packages
    packageID
    package
    packageDetails
    destination
    destinationDetails
    etc
    If there is a one to many relationship, then the following would be true
    packages
    packageID
    package
    packageDetails
    etc
    destinations
    destinationID
    packageID
    destination
    destinationDetails
    etc
    The above assumes that there are many destinations to one package with the relationship coloured orange.
    Once you have the above correct you can apply your query as follows
    SELECT *
    FROM packages
    INNER JOIN destinations
    ON packages.packageID = destinations.packageID
    WHERE packages.packageID = %s
    ORDER BY destination ASC
    The above query will show all packages with relevant destinations

  • Inner join query used with 7 Database tables

    HI All,
    In a report they used the Inner join Query with 6 Data base table..now there is a performance issue with at query.
    its taking so much of time to trigger that query. Please help how to avoid that performance issue for that.
    In that 2 database tables containing lakhs of records..
    According to my knowledge it can be avoided by using secondary indexs for those 2 database tables..
    and by replacing the Inner join Query with FOR ALL ENTRIES statement.
    i want how to use the logic by using FORALL ENTRIES statement for this..
    So, please give you proper suggestion to avoid this issue..
    Thanking you.
    Moderator message: Please Read before Posting in the Performance and Tuning Forum
    Edited by: Thomas Zloch on Oct 16, 2011 10:27 PM

    Hi,
    And what do you mean with "they used"? If "SAP used" then yo will need to ask a SAP for note
    FOR ALL ENTRIES is quite good described in help. Please search forum also.
    Without query it won't be possible to tell how it can be optimized, however you can try to use SE30/SAT and ST05. Maybe it will help you.
    BR
    Marcin Cholewczuk

  • Inner Join. How to improve the performance of inner join query

    Inner Join. How to improve the performance of inner join query.
    Query is :
    select f1~ablbelnr
             f1~gernr
             f1~equnr
             f1~zwnummer
             f1~adat
             f1~atim
             f1~v_zwstand
             f1~n_zwstand
             f1~aktiv
             f1~adatsoll
             f1~pruefzahl
             f1~ablstat
             f1~pruefpkt
             f1~popcode
             f1~erdat
             f1~istablart
             f2~anlage
             f2~ablesgr
             f2~abrdats
             f2~ableinh
                from eabl as f1
                inner join eablg as f2
                on f1ablbelnr = f2ablbelnr
                into corresponding fields of table it_list
                where f1~ablstat in s_mrstat
                %_HINTS ORACLE 'USE_NL (T_00 T_01) index(T_01 "EABLG~0")'.
    I wanted to modify the query, since its taking lot of time to load the data.
    Please suggest : -
    Treat this is very urgent.

    Hi Shyamal,
    In your program , you are using "into corresponding fields of ".
    Try not to use this addition in your select query.
    Instead, just use "into table it_list".
    As an example,
    Just give a normal query using "into corresponding fields of" in a program. Now go to se30 ( Runtime analysis), and give the program name and execute it .
    Now if you click on Analyze button , you can see, the analysis given for the query.The one given in "Red" line informs you that you need to find for alternate methods.
    On the other hand, if you are using "into table itab", it will give you an entirely different analysis.
    So try not to give "into corresponding fields" in your query.
    Regards,
    SP.

  • Regarding Inner join query

    Hi Guriji,s
    I wrote one inner join query. it is working fine. but when i exceute this query it is fetching the data only 261 movement type but but i also fetch the data movement type 201. for this plz tell me the correction in this query.
    select amatnr awerks abwart bbudat into table t_itab from mseg as a inner join mkpf as b
          on amblnr = bmblnr
             where awerks in plant and  abwart =  '261' or a~bwart = '201'
           and  btcode2 = 'mb1a' or btcode2 = 'mfbf' .
    thanks.

    Hi Sachin
    try to use like below
    select amatnr awerks abwart bbudat into table t_itab from mseg as a inner join mkpf as b
    on amblnr = bmblnr
    where awerks in plant and  ( abwart = '261' or a~bwart = '201' )
    and  ( btcode2 = 'mb1a' or btcode2 = 'mfbf' ).
    or try to fill ranges like select-options or use like
    select amatnr awerks abwart bbudat into table t_itab from mseg as a inner join mkpf as b
    on amblnr = bmblnr
    where awerks in plant and  abwart in ('261', '201')
    and btcode2 = 'mb1a' or btcode2 = 'mfbf' .
    Regards
    Praveen

  • Need help with inner join and distinct rows

    Hey Guys,
    i have
    1) BaseEnv Table 
    2) Link Table
    3) BaseData Table
    Link table has three columns Id,BaseEnvId,BaseDataId 
    the BaseEnvID is unique in the table where as BaseDataId can be repeated i.e multile rows of BaseEnv Table can point to same BaseData  table row
    Now i want to do  BaseEnvTable inner join Link Table inner join BaseData Table and select 5 columsn ; Name,SyncName,Version,PPO,DOM  from the BaseData table.. the problem is that after i do the inner join I get duplciate records..
    i want to eliminate the duplicate records , can any one help me here

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
    use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. Now we have to guess and type, guess and type, etc. because of your bad manners. 
    CREATE TABLE Base_Env
    (base_env_id CHAR(10) NOT NULL PRIMARY KEY,
    Think about the name Base_Data; do you have lots of tables without data? Silly, unh? 
    CREATE TABLE Base_Data
    (base_data_id CHAR(10) NOT NULL PRIMARY KEY,
    Your Links table is wrong in concept and implementation. The term “link” refers to a pointer chain structure used in network databases and makes no sense in RDBMS. There is no generic, magic, universal “id” in RDBMS! People that do this are called “id-iots”
    in SQL slang. 
    We can model a particular relationship in a table by referencing the keys in other tables. But we need to know if the relationship is 1:1, 1:m, or n:m. This is the membership of the relationship. Your narrative implies this: 
    CREATE TABLE Links
    (base_env_id CHAR(10) NOT NULL UNIQUE
       REFERENCES Base_Env (base_env_id),
     base_data_id CHAR(10) NOT NULL
       REFERENCES Base_Data (base_data_id));
    >> The base_env_id is unique in the table where as base_data_id can be repeated I.e multiple rows of Base_Env Table can point [sic] to same Base_Data table row. <<
    Again, RDBMS has no pointers! We have referenced an referencing tables. This is a fundamental concept. 
    That narrative you posted has no ON clauses! And the narrative is also wrong. There is no generic “name”, etc. What tables were used in your non-query? Replace the ?? in this skeleton: 
    SELECT ??.something_name, ??.sync_name, ??.something_version, 
           ??.ppo, ??.dom
    FROM Base_Env AS E, Links AS L, Base_Data AS D
    WHERE ?????????;
    >> I want to eliminate the duplicate records [sic], can any one help me here?<<
    Where is the sample data? Where is the results? Please read a book on RDBMS so you can post correct SQL and try again. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Help: Modifying inner join

    Hello Folks,
    I have an Access Query and am rewriting the whole query in Oracle to run a report.The thing is Am a beginner in oracle and am scratching my head on how to modify this inner join. please help me in rewriting this inner join in oracle. thanks a million
       ((Debtor INNER JOIN MAX_TRANS_DATE AS MAX_TRANS_DATE_1 ON Debtor .
            EVENT_ID = MAX_TRANS_DATE_1.EVENT_ID) INNER JOIN
            TMP$ALL_RECOVERY_TYPE
            ON(Debtor . EVENT_CASE_ID = TMP$ALL_RECOVERY_TYPE . EVENT_CASE_ID) AND
            (Debtor . EVENT_ID = TMP$ALL_RECOVERY_TYPE . EVENT_ID))
    INNER JOIN CUBS TRANSACTIONS
        ON (Debtor . EVENT_ID = CUBS TRANSACTIONS . EVENT_ID)
       AND (Debtor . EVENT_CASE_ID = CUBS TRANSACTIONS . EVENT_CASE_ID)

    Thanks for getting back. But still am unable to get the correct data. I will try to break it down.
    Microsoft Access Table MAX_TRANS_DATE menitoned above in the inner join was originally coming from table called TRANSACTIONS i.e.( MAX_TRANS_DATE = SELECT [Transactions].[EVENT_ID], Max([Transactions].[TRANSDATE]) AS MaxOfTRANSDATE
    FROM Debtor INNER JOIN Transactions ON [Debtor].[EVENT_ID]=[Transactions].[EVENT_ID]
    GROUP BY [Transactions].[EVENT_ID];
    Here the problem is am recreating the access database query in oracle database and we dont have MAX_TRANS_DATE in the Oracle database but we do have TRANSACTIONS table.
    So i just used TRANSACTIONS in the inner join instead of MAX_TRANS_DATE.
    But the result is wrong.The Field Transdate from TRANSACTIONS is pulling dates as 10/5/2006 instead of 02/01/2010. I suspect something is wrong with the joins.Please help me. I can provide the old access query and the new oracle query that i have created.
    Thanks
    Edited by: user11961230 on Mar 5, 2010 11:49 AM

  • Help With Inner Join

    Hi,
    Can some one explain me this issue
    SELECT COUNT(*) FROM "ECCDATA"."CUST1"  O/P = 800
    SELECT COUNT(*) FROM "ECCDATA"."CUST1"  WHERE MANDT = '800' O/P = 800
    SELECT COUNT(*) FROM "ECCDATA"."CUST2"  O/P = 13779
    SELECT COUNT(*) FROM "ECCDATA"."CUST2"  WHERE MANDT = '800'    O/p = 13751
    SELECT COUNT(*) FROM ( SELECT T1."A1", T2."MANDT" FROM "ECCDATA"."CUST1" AS T1
    INNER JOIN  "ECCDATA"."A2" AS T2
    ON T1."A1" = T2."A1" AND
       T2."MANDT" = '800' )      O/P = 13783
    SELECT COUNT(*) FROM ( SELECT T1."A1", T2."MANDT" FROM "ECCDATA"."CUST1" AS T1
    INNER JOIN  "ECCDATA"."A2" AS T2
    ON T1."A1" = T2."A1" AND
       T1."MANDT" = T2."MANDT")      O/P = 13779
    Thanks

    Hi Hari,
    SELECT COUNT(*) FROM "ECCDATA"."CUST2"  O/P = 13779
    SELECT COUNT(*) FROM "ECCDATA"."CUST2"  WHERE MANDT = '800'    O/p = 13751
    The table "ECCDATA"."CUST2" must be having client specific data other than of 800 client. Try the below query and check it.
    SELECT DISTINCT MANDT from "ECCDATA"."CUST2";
    May be you check the same for other tables too.
    Sreehari

  • Help with Inner join problem

    The following query works fine as long as there is a value in the subID field, which is at the end of the inner join statement. If the subID is blank then no data is output, even though it is there. Try as I may, I can not get the right solution in the where statement to get the data to show without the subID. What am I missing?
    <cfquery name="getInfo" datasource="#application.database#">
    select page_id, pageName, pages.content, pages.cat_id, pages.seo_title,pages.seo_desc,pages.seo_words,pages.h1_title,pages.pic,pages.brochure,pa ges.video,catagories.catagory,subcat.subID,subcat.sub_category
    from (pages INNER JOIN catagories ON pages.cat_id = catagories.cat_id) INNER JOIN subcat ON pages.subID = subcat.subID
    where pages.page_id = #page_id#
    </cfquery>

    Rick,
    Looks like you need a LEFT OUTER join to the "subcat" table, so that all records for "pages" and "catagories" are returned even if no matching "subcat" records exist.  INNER joins will only return selected records when the tables on both sides of the join statement have matching values, while a LEFT OUTER (sometimes also known simply as a LEFT join) join will return *all* selected records from the table(s) on the left side of the join statement regardless of whether there are matching records from the table on the right side of the join statement.  When there are no matching records from the table on the right side of the join statement, any columns in your SELECT clause that are from the table on the right side of the join statement will contain NULLs.
    HTH,
    -Carl V.

  • Help with inner join PLEASE IGNORE

    Hi I was doing a select with a subquery but I need that the where clause check to values so I couldn't get it so I decided to create a INNER JOIN
    Before
    insert into BPMTEMP (select * from ODS_VIEWER.BAN_EVENTOS_CONFIRMACION@DBLINK1 where id_solicitud and accion not in (select (id_solicitud, accion) from ODS_VIEWER.BAN_CONFIRMA_RESPUESTA@DBLINK1) and rownum <=200);but the problem with the inner join is that it doesn't accept me the external database source
    insert into BPMTEMP (select ODS_VIEWER.BAN_EVENTOS_CONFIRMACION@DBLINK1.*, ODS_VIEWER.BAN_CONFIRMA_RESPUESTA@DBLINK1.*
    from ODS_VIEWER.BAN_EVENTOS_CONFIRMACION@DBLINK1
    INNER JOIN ODS_VIEWER.BAN_CONFIRMA_RESPUESTA@DBLINK1
    ON [email protected]_solicitud = [email protected]_solicitud
    ON [email protected] = [email protected]
    AND rownum <=200); it shows an:
    ORA-02084:
         database name is missing a component
    Cause:      supplied database name cannot contain a leading '.', trailing '.' or '@', or two '.' or '@' in a row.
    how can I solve this????
    thanks for your help
    Edited by: Diego Guillen on 29/12/2009 11:14 AM

    Hi
    Please remove the @dblink stuff in the column descrptions or use a table alias. This should help.
    drop database link lokal;
    create database link lokal
       CONNECT TO whateveruserineed IDENTIFIED BY whateverthing
       USING 'lokal11g';
    select HR.COUNTRIES.*  from HR.COUNTRIES@lokal;
    select x.* from HR.COUNTRIES@lokal x;And as Dan Morgans says, pls. post you ? in the right forum next time :-))
    Mette

  • Inner join query

    Hi all,
    I want to query a inner join via some tools in sap GUI. till now, i could not query a inner join between two tables via SE11. can someone tell are there some other ways to achieve this?
    any response will be awarded!
    thanks and regards,
    samson

    hi samson,
    Proper use of Inner Join
    When multiple SAP tables are logically joined, it is always advisable to use inner join to read the data from them. This certainly reduces the load on the network.
    Let us take an example of 2 tables, zairln and zflight. The table zairln has the field airln, which is the airline code and the field lnnam, which is the name of the airline. The table zflight has the field airln, the airline code and other fields which hold the details of the flights that an airline operates.
    Since these 2 tables a re logically joined by the airln field, it is advisable to use the inner join.
                 Select aairln alnnam bfligh bcntry into table int_airdet
    example 2:--
    Inner join: If you have common fields between 2 or more tables, its betterto use Inner join.
    Check the below example:
    VBAK & VBAP table has common fields, hence we can use inner join.
    SELECT akunnr avbeln anetwr abnddt a~knumv
    avkbur aerdat avdatu aaugru
    aktext bmatnr barktx bkwmeng b~kzwi6
    bvolum bposnr b~kdmat
    INTO CORRESPONDING FIELDS OF TABLE g_t_quot
    FROM vbak AS a INNER JOIN vbap AS b
    ON avbeln = bvbeln
    WHERE a~vbeln IN so_vbeln
    AND a~trvog ='2'
    AND a~vkorg IN so_vkorg
    AND a~vtweg IN so_vtweg
    AND a~vkbur IN so_vkbur
    AND a~audat IN so_audat
    AND a~kunnr IN so_kunag.
    FOR ALL ENTRIES:
    If you get some data into one internal table and if you want to fetch data from other table based on it, use FOR ALL ENTRIES.
    g_t_quot is an internal table.
    SELECT spras augru bezei FROM tvaut INTO TABLE g_t_tvaut
    FOR ALL ENTRIES IN g_t_quot
    WHERE augru = g_t_quot-augru AND spras = sy-langu.
                From zairln as a inner join zflight as b on aairln = bairln.
    In order to restrict the data as per the selection criteria, a where clause can be added to the above inner join.

  • Help:Nested Inner Join

    Hello Folks,
    I have a query which has a nested Inner Join as follows
    INNER JOIN(Client
    INNER JOIN CUBS SNAPSHOT ON Client . Client = CUBS SNAPSHOT . CLIENT) ON CancelDesc . CancelReason = CUBS SNAPSHOT . CANCELREASONcouldnt figure out wat is the quivalent of this nested inner join in Oracle Server. I am trying to create a report based on this inner join of a query. Can anyone throw some light on this.
    Thanks

    Hi,
    Inner joins don't need to be nested. The results will be the same, no matter in what order the tables are joined.
    In Oracle, don't use table names with spaces in them, and don't put spaces before or after the dots that separate table name qualifiers from column names.
    I think this is what you want:
    INNER JOIN     cubs_snapshot  ON     CancelDesc.CancelReason = cubs_snapshot.cancelreason
    INNER JOIN     Client            ON     Client.Client           = cubs_snapshot.clientWhenever you have a question, post a little sample data (CREATE TABLE and INSERT statememts) for all tables invlovled, and the results you want from that data.
    If you really did need to nest joins, you could join some tables in a sub-query, then use the result set of that sub-query as if it were a table.
    For example:
    WITH  cubs_and_client            AS
         SELECT     CancelReason
         ,     ...     -- Whatever other columns are needed in superior query or queries
         FROM          client
         INNER JOIN     cubs_snapshot     ON     Client.Client           = cubs_snapshot.client
    SELECT     
    INNER JOIN     cubs_and_client     ON     CancelDesc.CancelReason = cubs_and_client.CancelReason
    ...In this example, the two tables cubs_snapshot and client are joined in a sub-query. The results of that sub-query can be referenced later in the query as if it were a table called cubs_and_client, very much like a view.

  • Inner join query syntax

    I have this query, however... I need the 'category' variable
    to be 'LIKE' but the way I have it set up it doent work. Anyone
    have an idea of how I might fix this.
    <CFQUERY name="getworkshops" datasource="source">
    SELECT m.category, m.proj_key, m.project, r.proj_key, r.url,
    r.category, r.end_date, r.title, e.event_date, e.event_date_end,
    e.category, e.proj_key
    FROM (main m INNER JOIN resource r ON m.category LIKE
    r.category)INNER JOIN event_cal e ON m.category LIKE e.category
    WHERE m.category like '%workshop%' AND m.proj_key=r.proj_key
    AND m.proj_key = e.proj_key
    ORDER BY m.proj_key
    </CFQUERY>

    You could move your join statements to your where clause:
    SELECT m.category, m.proj_key, m.project, r.proj_key, r.url,
    r.category, r.end_date, r.title, e.event_date, e.event_date_end,
    e.category, e.proj_key
    FROM main m, resource r, event_cal e
    WHERE m.category LIKE '%'+r.category+'%'
    AND m.category LIKE '%" + e.category + '%'
    AND m.category like '%workshop%' AND m.proj_key=r.proj_key
    AND m.proj_key = e.proj_key
    ORDER BY m.proj_key
    I had to guess on how you wanted to match m.category against
    resource and event_cal, but you get the idea.

  • Alias for field in inner join query

    In my Oracle 9i Schema, I have two tables:TableOne
    pocOne    pocTwo
    2           3
    2           4
    1           2
    TableTwo
    TableTwoId   Name
    1            Jones
    2            Smith
    3            Edwards
    4            CamdenMy SQL that works to fetch all records with Smith works great:select Name from TableTwo
    Inner Join TableOne
    on TableTwo.TableTwoId in (TableOne.pocOne, TableOne.pocTwo)
    where Name = 'Smith' Now I need to create an alias for the Name field. Here is my attempt:select myAliasName from TableTwo
    Inner Join TableOne
    on TableTwo.TableTwoId in (TableOne.pocOne, TableOne.pocTwo), (select Name as myAliasName from TableTwo)
    where myAliasName = 'Smith' This attempt pulls up all the records instead of just Smith records. Please advise how I can create an alias for the Name field in my above query?

    Are you just looking for
    select Name AS AliasName
       from TableTwo Inner Join TableOne
              on TableTwo.TableTwoId in (TableOne.pocOne, TableOne.pocTwo)
    where Name = 'Smith' Justin

  • Inner join query not working properly

    Hi everyone,
    It does not gives any error, but it is not fetching any values...but when i dont include fourth table CSKT AND THE FIELD LTEXT it is fetching the values.
    SELECT SINGLE
          T1~PERNR
          T1~BEGDA
          T1~ENAME
          T1~PLANS
          T1~KOSTL
          T2~STRAS
          T2~PSTLZ
          T2~ORT01
          T3~PLSTX
          T4~LTEXT
          INTO  FS_TAB
          FROM PA0001 AS T1
          INNER JOIN PA0006 AS T2 ON T1PERNR eq T2PERNR
          INNER JOIN T528T AS T3 ON T1PLANS EQ T3PLANS
          INNER JOIN CSKT AS T4 ON T1KOSTL EQ T4KOSTL
          WHERE T1~PERNR eq p_pernr.

    Change like this
    SELECT SINGLE
    T1~PERNR
    T1~BEGDA
    T1~ENAME
    T1~PLANS
    T1~KOSTL
    T2~STRAS
    T2~PSTLZ
    T2~ORT01
    T3~PLSTX
    T4~LTEXT
    INTO FS_TAB
    FROM PA0001 AS T1
    INNER JOIN PA0006 AS T2 ON T1~PERNR eq T2~PERNR
    INNER JOIN T528T AS T3 ON T1~PLANS EQ T3~PLANS
    LEFT OUTER JOIN CSKT AS T4 ON T1~KOSTL EQ T4~KOSTL
    WHERE T1~PERNR eq p_pernr.
    OR
    SELECT SINGLE
    T1~PERNR
    T1~BEGDA
    T1~ENAME
    T1~PLANS
    T1~KOSTL
    T2~STRAS
    T2~PSTLZ
    T2~ORT01
    T3~PLSTX
    T4~LTEXT
    INTO FS_TAB
    FROM PA0001 AS T1
    LEFT OUTER JOIN PA0006 AS T2 ON T1~PERNR eq T2~PERNR
    LEFT OUTER JOIN T528T AS T3 ON T1~PLANS EQ T3~PLANS
    LEFT OUTER JOIN CSKT AS T4 ON T1~KOSTL EQ T4~KOSTL
    WHERE T1~PERNR eq p_pernr.
    as long as the table is not used in where condition, u can use left outter join.

Maybe you are looking for

  • Adding PHP pages, not showing dynamic content?

    Hi all, I'm new and hoping I don't get ripped apart for a question that seems simple. I've looked a lot though and can't seem to find an exact scenario like this. I recently took over a PHP site for a friend that was built in Dreamweaver CS3. There's

  • IPod nano 3rd gen. freezes on doc

    My daughters iPod freezes when you put it on any docking station. We have tried resetting it, updating it etc... But unfortunately what ever we try it only works for a short time, if at all! Needless to say, it started playing up when it was about 10

  • Upgrade options from Mac OS X 10.5.8 ??

    I have a MacBook Pro from 2009 with Mac OS X 10.5.8. What are my options to update/upgrade the OS X??

  • Abap insert into info cube results in ORA 14400

    Hi friends, in principle the situation is as following: we have 2 cubes which are identically in design, in the number of info objects etc. now we have the following code here:                                                                    * Dann

  • Updating the Project Panel in PPro CS6 is horrendously slow! (But nothing else is affected)

    Anytime I make a change to the project panel whether it's moving a clip to a folder, adding a description, or anything.... it freezes up for around 20 seconds before it does anything?! All other performance of PPro CS6 is fine - Timeline, Source and