Inner join in crystal 2008

Hi All,
         I am new to Crystal report 2008, i have  a requirement in which i have to make new  connection to Access database which has two tables in it. I have to inner join two tables in crystal reports where the condition is that 1st table contains date and time field and other table has only month. I have to inner join these two fields with key month.Can it be done in crystal reports or i have work on Access itself?
Regards,
Vikram Sukumar

Hi Vikram,
You should be able to do it in CR as long as the data types are compatibles:
-Create blank report;
-From Database Expert, create connection to Access then select the tables to use in the report (if at least 2 tables are selected, the 'Links' tab will appear);
-Go to 'Links' tab;
-Drag a field from one table to a field in another table.
If successful, a link line is created. If unsuccessful, a message is issued.
Note: You can link tables by table name or by foreign key information.
Note: When manually creating links, the field you are linking "to" must be of the same data type as the field you are linking from

Similar Messages

  • Need to adjust SQL query for left outer join in Crystal Reports 2008.

    I need to change this SQL 2005 query.....
    SELECT     omnicell_anl.DeviceIDsLastMetricTable.member_id, omnicell_anl.DeviceIDsLastMetricTable.[Device Name],
                          omnicell_anl.DeviceIDsLastMetricTable.Account, omnicell_anl.labeledLastMetrics.PROPERTY_NAME,
                          omnicell_anl.labeledLastMetrics.latest_monitor_value
    FROM         omnicell_anl.DeviceIDsLastMetricTable LEFT OUTER JOIN
                          omnicell_anl.labeledLastMetrics ON omnicell_anl.DeviceIDsLastMetricTable.member_id = omnicell_anl.labeledLastMetrics.member_id
    WHERE
        omnicell_anl.labeledLastMetrics.PROPERTY_NAME = ?MyProperty
    To this query in Crystal Reports Report Writer:
    SELECT     omnicell_anl.DeviceIDsLastMetricTable.member_id, omnicell_anl.DeviceIDsLastMetricTable.[Device Name],
                          omnicell_anl.DeviceIDsLastMetricTable.Account, omnicell_anl.labeledLastMetrics.PROPERTY_NAME,
                          omnicell_anl.labeledLastMetrics.latest_monitor_value
    FROM         omnicell_anl.DeviceIDsLastMetricTable LEFT OUTER JOIN
                          omnicell_anl.labeledLastMetrics ON omnicell_anl.DeviceIDsLastMetricTable.member_id = omnicell_anl.labeledLastMetrics.member_id AND
                          omnicell_anl.labeledLastMetrics.PROPERTY_NAME = ?MyProperty
    I can't seem to get the left outer join function of Crystal Reports to emulate the same SQL query in SQL 2005.  Any ideas on how I can create this same query in Crystal 2008?
    Thanks,
    Dominic
    Edited by: Dominic Carissimi on Oct 28, 2008 7:55 PM
    Edited by: Dominic Carissimi on Oct 28, 2008 7:56 PM

    If you want the list of values for command level parameter then you need to add another command like
    select PropertyField from table
    and delete the links between this command and the existing command.
    Now go to field explorer and edit the command level parameter and make it as dynamic and add the property field from newly added command.
    Hope this helps!
    Raghavendra

  • INNER JOIN PROBLEM IN Microsoft SQL Server 2008 R2 Report Builder 3.0

    SELECT
    ,maximo_tbl_matrectrans.ponum
    ,maximo_tbl_po.description AS [maximo_tbl_po description]
    ,maximo_tbl_matrectrans.polinenum
    ,maximo_tbl_matrectrans.itemnum
    ,maximo_tbl_item.description AS [maximo_tbl_item description]
    FROM
    maximo_tbl_matrectran
    INNER JOIN maximo_tbl_po
    ON maximo_tbl_matrectrans.ponum = maximo_tbl_po.ponum
    INNER JOIN maximo_tbl_item
    ON maximo_tbl_matrectrans.itemnum = maximo_tbl_item.itemnum
    can you advise below picture in itemnum in show one value more time
    ponum polinenum maximo_tbl_a_po_description itemnum maximo_tbl_a_item_description
    D33-1021425 5 ASL REORDER HAZMAT 91G8110000071 DRUM, PLASTIC
    D33-1021425 5 ASL REORDER HAZMAT 91G8110000071 DRUM, PLASTIC
    D33-1020817 2 ASL REPLENISHMENT, D 91G6685000371 THERMOSTAT
    D33-1020817 2 ASL REPLENISHMENT, D 91G6685000371 THERMOSTAT
    D33-1020817 2 ASL REPLENISHMENT, D 91G6685000371 THERMOSTAT
    D33-1021365 2 ASL - D33DFAC STOCK 91G3920000081 CART, BIG WHEEL
    D33-1021365 2 ASL - D33DFAC STOCK 91G3920000081 CART, BIG WHEEL
    D33-1021425 5 ASL REORDER HAZMAT 91G8110000071 DRUM, PLASTIC
    D33-1020817 1 ASL REPLENISHMENT, D 91G5330002011 SEAL, THERMOSTAT
    D33-1022346 2 ASL STOCK REORDER E 92G6145000998 CABLE, POWER,
    D33-1022346 2 ASL STOCK REORDER E 92G6145000998 CABLE, POWER,
    D33-1020817 1 ASL REPLENISHMENT, D 91G5330002011 SEAL, THERMOSTAT
    D33-1020817 1 ASL REPLENISHMENT, D 91G5330002011 SEAL, THERMOSTAT
    D33-1022346 2 ASL STOCK REORDER E 92G6145000998 CABLE, POWER,
    but original we need..
    ponum polinenum maximo_tbl_a_po_description itemnum maximo_tbl_a_item_description
    D33-1021425 5 ASL REORDER HAZMAT 91G8110000071 DRUM, PLASTIC
    D33-1020817 2 ASL REPLENISHMENT, D 91G6685000371 THERMOSTAT
    D33-1021365 2 ASL - D33DFAC STOCK 91G3920000081 CART, BIG WHEEL
    D33-1020817 1 ASL REPLENISHMENT, D 91G5330002011 SEAL, THERMOSTAT
    D33-1022346 2 ASL STOCK REORDER E 92G6145000998 CABLE, POWER,

    Try below:
    SELECT DISTINCT
    maximo_tbl_matrectrans.ponum
    ,maximo_tbl_po.description AS [maximo_tbl_po description]
    ,maximo_tbl_matrectrans.polinenum
    ,maximo_tbl_matrectrans.itemnum
    ,maximo_tbl_item.description AS [maximo_tbl_item description]
    FROM
    maximo_tbl_matrectran
    INNER JOIN maximo_tbl_po
    ON maximo_tbl_matrectrans.ponum = maximo_tbl_po.ponum
    INNER JOIN maximo_tbl_item
    ON maximo_tbl_matrectrans.itemnum = maximo_tbl_item.itemnum
    -Vaibhav Chaudhari

  • Report - INNER JOIN Problem

    Hi,
    In my report List of Block Customer's, INNER JOIN is not working..
    Code:----
    SELECT DISTINCT M1KUNNR M1KTOKD M1NAME1 M1CASSD M1AUFSD M1LIFSD M1~FAKSD INTO CORRESPONDING FIELDS OF TABLE ITAB
                        FROM KNA1 AS M1 INNER JOIN KNVV AS M2 ON M1KUNNR = M2KUNNR
                                               WHERE M1~KTOKD IN ('0001' , 'KTOKD')
                                                AND M1~CASSD EQ 'X'
                                                 OR M1~AUFSD NE ''
                                                 OR M1~LIFSD NE ''
                                                 OR M1~FAKSD NE ''
                                                 OR (M2~AUFSD NE ''
                                                 OR M2~LIFSD NE ''
                                                 OR M2~FAKSD NE ''
                                                 OR M2~CASSD EQ 'X'.
    Here, condition on 0001 is not matching..
    Plz tell me, what is the problem in it..
    Thanks
    Edited by: Prince Kumar on Oct 20, 2008 9:37 AM

    hi,
    please use " FOR ALL ENTRIES " as it is better performance wise also rather then inner joins
    and for syntax refer this code:
    Exporting all flight data for a specified departure city. The relevant airlines and flight numbers are first put in an internal table entry_tab, which is evaluated in the WHERE condition of the subsquent SELECT statement.
    PARAMETERS p_city TYPE spfli-cityfrom.
    TYPES: BEGIN OF entry_tab_type,
             carrid TYPE spfli-carrid,
             connid TYPE spfli-connid,
           END OF entry_tab_type.
    DATA: entry_tab   TYPE TABLE OF entry_tab_type,
          sflight_tab TYPE SORTED TABLE OF sflight
                           WITH UNIQUE KEY carrid connid fldate.
    SELECT carrid connid
           FROM spfli
           INTO CORRESPONDING FIELDS OF TABLE entry_tab
           WHERE cityfrom = p_city.
    SELECT carrid connid fldate
           FROM sflight
           INTO CORRESPONDING FIELDS OF TABLE sflight_tab
           FOR ALL ENTRIES IN entry_tab
           WHERE carrid = entry_tab-carrid AND
                 connid = entry_tab-connid.
    thanks and regards
    RAHUL

  • Select Query with Inner Join

    Dear Experts,
    I have writen a inner join code with MKPF and MSEG which taking too much time, while I have used index.
    Indexes are:
    MSEG
    MATNR
    WERKS
    LGORT
    BWART
    SOBKZ
    MKPF
    BUDAT
    MBLNR
    My Select Query is :
      SELECT B~MATNR
                   B~MAT_KDAUF
                   B~MAT_KDPOS
                   B~BWART
                   B~MENGE
                   B~MEINS
                   B~AUFNR
        INTO TABLE IT_MSEG
        FROM MKPF AS A
          INNER JOIN MSEG AS B
             ON AMBLNR EQ BMBLNR
            AND AMJAHR EQ BMJAHR
        WHERE A~BUDAT IN BUDAT
          AND B~MATNR IN MATNR
          AND B~WERKS IN WERKS
          AND B~LGORT IN LGORT
          AND B~BWART IN BWART.

    hi,
    you can use  for all entries  it will work faster then joins
    About it:*
    FOR ALL ENTRIES WHERE
    Syntax
    ... FOR ALL ENTRIES IN itab WHERE ... col operator itab-comp ...
    Effect
    If the addition FOR ALL ENTRIES is specified before the language element WHERE, then the components comp of the internal table itab can be used as operands when comparing with relational operators.
    The internal table itab must have a structured line type and the component comp must be compatible with the column col.
    The logical expression sql_cond of the WHERE condition can comprise various logical expressions by using AND and OR. However, if FOR ALL ENTRIES is specified, there must be at least one Comparison with a column of the internal table itab, which can be specified either statistically or dynamically (Release 6.40 and higher). In a statement with a SELECTstatement with FOR ALL ENTRIES, the addition ORDER BY can only be used with the addition PRIMARY KEY.
    The whole logical expression sql_cond is evaluated for each individual line of the internal table itab. The resulting set of the SELECT statement is the union of the resulting sets from the individual evaluations. Duplicate lines are automatically removed from the resulting set. If the internal table itab is empty, the whole WHERE statement is ignored and all lines in the database are put in the resulting set.
    Notes
    In Release 6.10 and higher, the same internal table can be specified after FOR ALL ENTRIES and after INTO.
    The addition FOR ALL ENTRIES is only possible before WHERE conditions of the SELECT statement.
    Example
    Exporting all flight data for a specified departure city. The relevant airlines and flight numbers are first put in an internal table entry_tab, which is evaluated in the WHERE condition of the subsquent SELECT statement.
    PARAMETERS p_city TYPE spfli-cityfrom.
    TYPES: BEGIN OF entry_tab_type,
             carrid TYPE spfli-carrid,
             connid TYPE spfli-connid,
           END OF entry_tab_type.
    DATA: entry_tab   TYPE TABLE OF entry_tab_type,
          sflight_tab TYPE SORTED TABLE OF sflight
                           WITH UNIQUE KEY carrid connid fldate.
    SELECT carrid connid
           FROM spfli
           INTO CORRESPONDING FIELDS OF TABLE entry_tab
           WHERE cityfrom = p_city.
    SELECT carrid connid fldate
           FROM sflight
           INTO CORRESPONDING FIELDS OF TABLE sflight_tab
           FOR ALL ENTRIES IN entry_tab
           WHERE carrid = entry_tab-carrid AND
                 connid = entry_tab-connid.
    hope it will help you
    Rahul sharma
    Edited by: RAHUL SHARMA on Sep 11, 2008 8:10 AM

  • Crystal 2008 doesn't work on 64Bit WHY!

    Dear All,
    i'm having trouble getting Crystal 2008 to work in a new Win 7, 64 bit system using CR oracle 4.10 ODBC connection. I can connect to the database via test button on the OBDC but whenever I try in crystal 2008 it says "connectino not open"
    Any thoughts?

    For scrollable panels within a scrollable window, you need to use two fingers to scroll in the inner panel.

  • Inner join taking more time

    Hi Experts,
    I have joined two table prps and proj by inner join . But it is taking more time.
    pls advice.
    the code is:
      select prps~posid                                        
             prps~post1
             prps~objnr
             prps~pbukr
             prps~prctr
             prps~erdat
             prps~zz_can
             into table  itab_prps_all
             from proJ inner join prps
             on projpspnr = prpspsphi
                  where prps~posid IN   sel_wbs
                  AND   prps~pbukr IN   sel_comp
                  AND   prps~prctr IN   sel_prct
                  AND   prps~erdat IN   sel_date
                  and   proj~pprof NE wa_pprof.
    thanks in advance,
    SG

    hi,
    plz use  FOR ALL ENTRIES IN  , it will increase performance of code
    example:
    Exporting all flight data for a specified departure city. The relevant airlines and flight numbers are first put in an internal table entry_tab, which is evaluated in the WHERE condition of the subsquent SELECT statement.
    PARAMETERS p_city TYPE spfli-cityfrom.
    TYPES: BEGIN OF entry_tab_type,
             carrid TYPE spfli-carrid,
             connid TYPE spfli-connid,
           END OF entry_tab_type.
    DATA: entry_tab   TYPE TABLE OF entry_tab_type,
          sflight_tab TYPE SORTED TABLE OF sflight
                           WITH UNIQUE KEY carrid connid fldate.
    SELECT carrid connid
           FROM spfli
           INTO CORRESPONDING FIELDS OF TABLE entry_tab
           WHERE cityfrom = p_city.
    SELECT carrid connid fldate
           FROM sflight
           INTO CORRESPONDING FIELDS OF TABLE sflight_tab
           FOR ALL ENTRIES IN entry_tab
           WHERE carrid = entry_tab-carrid AND
                 connid = entry_tab-connid.
    thanks and regards
    rahul sharma
    Edited by: RAHUL SHARMA on Sep 18, 2008 7:24 AM
    Edited by: RAHUL SHARMA on Sep 18, 2008 7:33 AM
    Edited by: RAHUL SHARMA on Sep 18, 2008 7:34 AM

  • Program without inner join..

    hi frds...
    i need help in the programming without using the inner join and views,
    i want to take  data from 2  different table without join and views, give some sample codes or links
    it will help to us.
    by
    pari..
    Edited by: Alvaro Tejada Galindo on Feb 22, 2008 12:18 PM

    Hi pari,
             This is the sample code 'for all entries'
    in alv report.
    TYPE-POOLS:SLIS.
    DATA:BODY TYPE SLIS_T_FIELDCAT_ALV,
         HEADER TYPE SLIS_FIELDCAT_ALV.
    DATA:BEGIN OF ITAB OCCURS 0,
         MATNR LIKE MARA-MATNR,
         ERSDA LIKE MARA-ERSDA,
         MEINS LIKE MARA-MEINS,
         END OF ITAB.
    DATA:BEGIN OF ITAB1 OCCURS 0,
         MATNR LIKE MAKT-MATNR,
         MAKTX LIKE MAKT-MAKTX,
         END OF ITAB1.
    DATA:BEGIN OF ITAB2 OCCURS 0,
         MATNR LIKE MARA-MATNR,
         ERSDA LIKE MARA-ERSDA,
         MEINS LIKE MARA-MEINS,
         MAKTX LIKE MAKT-MAKTX,
        END OF ITAB2.
    SELECT-OPTIONS:SMATNR FOR ITAB-MATNR.
    PERFORM FETCH_MARA.
    PERFORM FETCH_MAKT.
    PERFORM READ.
    PERFORM FIELDCATALOG.
    PERFORM ALVDISPLAY.
    *&      Form  FETCH_MARA
    form FETCH_MARA .
    SELECT MATNR ERSDA MEINS FROM MARA INTO TABLE ITAB WHERE MATNR IN SMATNR
    endform.                    " FETCH_MARA
    *&      Form  FETCH_MAKT
    form FETCH_MAKT .
    IF ITAB[] IS NOT INITIAL.
    SELECT MATNR MAKTX FROM MAKT INTO TABLE ITAB1 FOR ALL ENTRIES IN ITAB
    WHERE MATNR = ITAB-MATNR.
    ENDIF.
    endform.                    " FETCH_MAKT
    FORM READ.
    LOOP AT ITAB.
    READ TABLE ITAB1 WITH KEY MATNR = ITAB-MATNR.
    IF SY-SUBRC = 0.
    MOVE ITAB-MATNR TO ITAB2-MATNR.
    MOVE ITAB-ERSDA TO ITAB2-ERSDA.
    MOVE ITAB-MEINS TO ITAB2-MEINS.
    MOVE ITAB1-MAKTX TO ITAB2-MAKTX.
    ENDIF.
    APPEND ITAB2.
    ENDLOOP.
    ENDFORM.
    *&      Form  FIELDCATALOG
          text
    -->  p1        text
    <--  p2        text
    form FIELDCATALOG .
    HEADER-COL_POS = '1'.
    HEADER-SELTEXT_L = 'MATNR1'.
    HEADER-TABNAME = 'ITAB2'.
    HEADER-FIELDNAME = 'MATNR'.
    APPEND HEADER TO BODY.
    CLEAR HEADER.
    HEADER-COL_POS = '2'.
    HEADER-SELTEXT_L = 'ERSDA'.
    HEADER-TABNAME = 'ITAB2'.
    HEADER-FIELDNAME = 'ERSDA'.
    APPEND HEADER TO BODY.
    CLEAR HEADER.
    HEADER-COL_POS = '3'.
    HEADER-SELTEXT_L = 'MEINS'.
    HEADER-TABNAME = 'ITAB2'.
    HEADER-FIELDNAME = 'MEINS'.
    APPEND HEADER TO BODY.
    CLEAR HEADER.
    HEADER-COL_POS = '4'.
    HEADER-SELTEXT_L = 'MAKTX'.
    HEADER-TABNAME = 'ITAB2'.
    HEADER-FIELDNAME = 'MAKTX'.
    APPEND HEADER TO BODY.
    CLEAR HEADER.
    endform.                    " FIELDCATALOG
    *&      Form  ALVDISPLAY
    form ALVDISPLAY .
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
       I_CALLBACK_PROGRAM             = 'ZALVREPORT'
      I_CALLBACK_PF_STATUS_SET       = ' '
      I_CALLBACK_USER_COMMAND        = ' '
      I_STRUCTURE_NAME               =
      IS_LAYOUT                      =
       IT_FIELDCAT                    = BODY
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
      IT_EVENTS                      =
      IT_EVENT_EXIT                  =
      IS_PRINT                       =
      IS_REPREP_ID                   =
      I_SCREEN_START_COLUMN          = 0
      I_SCREEN_START_LINE            = 0
      I_SCREEN_END_COLUMN            = 0
      I_SCREEN_END_LINE              = 0
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
      TABLES
        t_outtab                       = ITAB2
    EXCEPTIONS
      PROGRAM_ERROR                  = 1
      OTHERS                         = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.

  • 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

  • About inner join in abap

    hi
        i am new to sap , i dont no about inner join in abap coding
    plz send me some notes or coding.
                            thank u.
                                                              your regrads
                                                                    divya.

    hi
    use this links
    INNER JOIN  and OUTER JOINhttp://help.sap.com/erp2005_ehp_03/helpdata/EN/cf/21ec77446011d189700000e8322d00/frameset.htm
    JOINED TABLES
    http://help.sap.com/erp2005_ehp_03/helpdata/EN/0f/49bd6a5d5049edba7b3afe6c7956e3/frameset.htm
    u will find all thins related to joins with example and how to use it
    Cheers
    Snehi
    Edited by: snehi chouhan on Jul 25, 2008 9:45 AM

  • Drag-n-n-drop query joins uses WHERE, not INNER JOIN syntax

    When I highlight a few tables and drag them onto the sql worksheet, it will build a select statement for me and join the tables by their foreign keys.
    That's a nice feature, thanks!
    Three questions. Is it possible to:
    1. get it to use the INNER JOIN and LEFT OUTER JOIN syntax instead of joining the tables in the WHERE clause?
    2. control the table aliases so that it will automatically use the "standard alias" for the table instead of A, B, C, etc.?
    3. get it to not put the schema name into the query?
    Thanks!
    Edited by: David Wendelken on Nov 22, 2008 1:48 PM. Grammar mistake.

    Hi Gopi,
    Your code is Good.
    But try to avoid Inner join with more number of Tables ...because this is a performance issue..
    try to use..
    select (primary key fields mainly,other fields) from LIKP into itab where bolnr in p_bolnr(paramater).
    next try to use for all entries option..
    select (primary key fields mainly,other fields) from VBFA for all entries in itab where (give the condition)....
    simillarly do for the other select ....ok this will try to reduce the performance issue....
    <b><REMOVED BY MODERATOR></b>
    Message was edited by:
            Alvaro Tejada Galindo

  • Inner join help

    Hello Friends,
    I am Debugging one report and I want to know the meaning of following Query, That what this querri is doing and what result will come, Please guide me as soon as possible.........
    SELECT abudat bmatnr bwerks cmtart SUM( b~menge ) AS xmenge
      INTO (budat, matnr, werks, mtart, menge)
      FROM ( ( mkpf AS a INNER JOIN mseg AS b ON amblnr = bmblnr )
                         INNER JOIN mara AS c ON bmatnr = cmatnr )
      WHERE a~budat IN p_budat
      AND b~bwart =  '101'
      AND ( blgort = 'FGSL' )"OR blgort = 'JWSL' OR b~lgort = 'SCRL' )
        AND a~mjahr = mjahr
        GROUP BY abudat bmatnr bwerks cmtart
        ORDER BY abudat bmatnr bwerks cmtart.
        itab-budat = budat.
        itab-matnr = matnr.
        itab-werks = werks.
        itab-mtart = mtart.
        itab-menge = menge.
        APPEND itab.
        CLEAR: itab, budat, matnr, werks, mtart, menge.
      ENDSELECT.

    Hi Friend,
    Ohh! i will guide you to write in efficeien way:
    1. SELECT data from MKPF, MSEG and MARA using inner join into an internal table. Where condition will be like as it is.
    You can not use SUM(MENGE) use only MENGE
    2. Use group by, order by with those clause on that internal table.
    3. Loop that internal table and use AT END OF BUDAT. SUM. END AT it will sum as required. Within that AT END AT pass values to an work are like itab. APPEND itab.
    Check the work are before appending, if you are not getting all value, pass to and local work area before AT.
    \[removed by moderator\]
    Regards
    Krishnendu
    Edited by: Jan Stallkamp on Jul 30, 2008 4:24 PM

  • Inner join is not removing duplicates!!

    Table name is customers
         CNUM     CNAME     CITY     RATING     SNUM
    1     2001     Hoffman     London     100     1001
    2     2002     Giovanni     Rome     200     1003
    3     2003     Liu     San Jose     200     1002
    4     2004     Grass     Berlin     300     1002
    5     2006     Clemens     London     100     1001
    6     2008     Cisneros     San Jose     300     1007
    7     2007     Perira     Rome     100     1004
    Query is
    To Find all pairs of customers haveing the same rating
    I have tried:
    SELECT c.cname,cb.cname FROM customers c INNER JOIN customers cb ON c.rating=cb.rating AND c.cname!=cb.cname
         CNAME     CNAME
    1     Perira     Hoffman
    2     Clemens     Hoffman
    3     Liu     Giovanni
    4     Giovanni     Liu
    5     Cisneros     Grass
    6     Perira     Clemens
    7     Hoffman     Clemens
    8     Grass     Cisneros
    9     Clemens     Perira
    10     Hoffman     Perira
    Ideally it should till 5 rows but it should not return such rows for an e.g. Hoffman Perira since I got Perira Hoffman already. Your repsonse will be appreciated.
    Thanks,
    Vaibhav

    Hi, Vaibhav,
    914683 wrote:
    Table name is customers
         CNUM     CNAME     CITY     RATING     SNUM
    1     2001     Hoffman     London     100     1001
    2     2002     Giovanni     Rome     200     1003
    3     2003     Liu     San Jose     200     1002
    4     2004     Grass     Berlin     300     1002
    5     2006     Clemens     London     100     1001
    6     2008     Cisneros     San Jose     300     1007
    7     2007     Perira     Rome     100     1004
    Query is
    To Find all pairs of customers haveing the same rating
    I have tried:
    SELECT c.cname,cb.cname FROM customers c INNER JOIN customers cb ON c.rating=cb.rating AND c.cname!=cb.cnameMaybe what you want is
    SELECT      c.cname
    ,         cb.cname
    FROM          customers  c
    INNER JOIN  customers  cb  ON   c.rating  = cb.rating
                                       AND  c.cname       < cb.cname     -- not !=
         CNAME     CNAME
    1     Perira     Hoffman
    2     Clemens     Hoffman
    3     Liu     Giovanni
    4     Giovanni     Liu
    5     Cisneros     Grass
    6     Perira     Clemens
    7     Hoffman     Clemens
    8     Grass     Cisneros
    9     Clemens     Perira
    10     Hoffman     PeriraThe title you chose for this thread is "inner join is not removing duplicates!!".
    Inner joins (or any other kinds of joins) are not supposed to remove duplicates. Use SELECT DISTINCT to remove duplicates, that is, completely identical rows.
    You don't have any duplicates. For example, these rows from your result set:
    `        CNAME     CNAME
    1     Perira     Hoffman
    10     Hoffman     Periraare not identical; in fact, both columns are different.
    Ideally it should till 5 rows but it should not return such rows for an e.g. Hoffman Perira since I got Perira Hoffman already. Please post the exact output you want from that sample data. (As Hoek said, you should post CREATE TABLE and INSERT statements for the sample data, too.)

  • SOLVED!!!Cross DB Link INNER JOIN resultingin 0 rows returned????

    Has anyone had experience with a JOIN not returning the result that the data shows it should?
    I am writing a query to join two tables across DBs and I know that most of the IDs in the joining columns do in fact match, but when I INNER JOIN, no rows are returned. As you would expect, a LEFT OUTER JOIN RESULTS in my right table showing and a full set of null values for each of the columns of the newly joined table.
    Has anyone come across this behavior?
    I can even do a select on the table to be joined and use the where clause to show that some of the values from the first table do in fact existed within the table to be joined.
    I'm frustrated and a little confused.
    Can anyone help?
    Message was edited by:
    DPotter

    Are the columns on which you are joining are of DATE datatype? If yes then without TRUNC you will be in trouble.
    If it is not the case give column datatypes and sample data.
    See the simple example below:
    SQL> SELECT 1 VAL
    FROM DUAL
    WHERE SYSDATE = TO_DATE('08-MAY-2008','DD-MON-YYYY') ;  2    3 
    no rows selected
    SQL> SELECT SYSDATE
    FROM DUAL;  2 
    SYSDATE
    08-MAY-08
    SQL>
    SELECT 1 VAL
    FROM DUAL
    WHERE TRUNC(SYSDATE) = TO_DATE('08-MAY-2008','DD-MON-YYYY') ;SQL>   2    3 
           VAL
             1

  • Inner join coding

    Hi gurus,
    Can anyone help me how to change the following select statement into inner join?
    SELECT aufnr FROM afpo INTO TABLE i_afpo
        WHERE projn = l_afpo-projn
           AND aufnr IN
          ( select AUFNR from AUFK WHERE auart = 'NT01' ).
        IF sy-subrc = 0.
          LOOP AT i_afpo.
            SELECT SINGLE aufpl INTO l_aufpl
            FROM afko
            WHERE aufnr = i_afpo-aufnr.
            IF sy-subrc = 0.
              SELECT objnr INTO TABLE i_afvc
              FROM afvc
              WHERE aufpl = l_aufpl.
    \[removed by moderator\]
    Thanks & Regards.
    Edited by: Jan Stallkamp on Jul 25, 2008 11:00 AM

    hiii
    it is better to use FOR ALL ENTRIES here..if you want to use it then just refer to following code..
    SELECT matnr                         " Material Number
        FROM mara
        INTO TABLE i_mara
       WHERE matnr IN s_matnr.
      IF i_mara[] IS NOT INITIAL.
        SELECT matnr                       " Material Number
               werks                       " Plants
               prctr                       " Profit Center
          FROM marc
          INTO TABLE i_marc
           FOR ALL ENTRIES IN i_mara
         WHERE matnr = i_mara-matnr
           AND werks IN s_werks.
      ENDIF.                               " IF i_mara[] IS NOT INITIAL
      i_output = i_marc.
      IF i_marc[] IS NOT INITIAL.
        SELECT matnr                       " Material Number
               werks                       " Plants
               lgort                       " Storage Location
          FROM mard
          INTO TABLE i_mard
           FOR ALL ENTRIES IN i_marc
         WHERE matnr EQ i_marc-matnr
           AND werks EQ i_marc-werks
           AND lgort IN s_lgort.
      ENDIF.                               " IF i_mara[] IS NOT INITIAL
    If it is needed to use inner join then just refer to following example in link..it will solve your problem
    http://www.sap-img.com/abap/select-statement-with-inner-join-is-taking-forever.htm
    regards
    twinkal

Maybe you are looking for