Problem of using formula in select join  statement

I  would like to use following statement but I can not.(do you have an example of an statement where this wuld work):
SELECT 
lipsprodh  sum(lipslfimg * lipsumvkz / lipsumvkn)  sum(lipsvolum)  lipsvtweg  likp~wadat_ist
INTO CORRESPONDING
FIELDS OF TABLE itab FROM
lips
JOIN likp 
ON lipsvbeln = likpvbeln
WHERE lips~vkorg = '0200'.

Hi  ,
types: BEGIN OF s_itab      ,
       prodh  LIKE lips-prodh,
       lfimg  LIKE lips-lfimg,
       umvkz  LIKE lips-umvkz,
       umvkn  LIKE lips-umvkn,
       volum  LIKE lips-volum,
       vtweg  LIKE lips-vtweg,
       wadat_ist LIKE likp-wadat_ist,
       END OF s_itab.
DATA : temp   type p decimal  2 ,
       temp1  type p decimal 2 ,
       temp2  type p decimal 2 ,
       itab   type table of s_itab ,
       wt_tab type s_itab .
SELECT lips~prodh
             lips~lfimg
             lips~umvkz
             lips~umvkn
             lips~volum
             lips~vtweg
             likp~wadat_ist
INTO CORRESPONDING FIELDS OF TABLE  itab
FROM  ( lips INNER JOIN likp ON lipsvbeln = likpvbeln )
WHERE lips~vkorg = '0200'.
loop at itab inro wt_tab .
temp   =  ( wt_tab-lfimg * wt_tab-umvkz ) / lips~umvkn  .
temp1 = temp1 + temp .
temp2 = temp2 + wt_tab .
endloop.
Hope it helped you .
Message was edited by:
        Lakshminarayanan rohini

Similar Messages

  • Problem in using aggregate functions inside case statement

    Hi All,
    I am facing problem while using aggregate functions inside case statement.
    CASE WHEN PSTYPE='S' THEN MAX(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) ELSE SUM(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) END,
    how can I achieve above requirement ? Con anyone help me.
    Thanks and Regards
    DG

    Hi All,
    Below is my query:
            SELECT
            CASE WHEN p_reportid IN ('POS_RV_SN','POS_PB') THEN POS.PACCT
            ELSE POS.PACCT || '-' || DECODE(POS.SYSTEMCODE,'GMI1','1', 'GMI2','2', 'GMI3','4', 'GMI4','3', '0') ||POS.PFIRM|| NVL(POS.POFFIC,'000') END,
            CASE WHEN p_reportid IN ('POS_RV_SN','POS_PB') THEN POS.PACCT||POS.PCUSIP||DECODE(POS.PBS,1,'+',2,'-')
            ELSE POS.PFIRM||POS.POFFIC||POS.PACCT||POS.PCUSIP||DECODE(POS.PBS,1,'+',2,'-') END,POS.SYSTEMCODE,CASE WHEN POS.PSTYPE='S' THEN POS.PSYMBL ELSE POS.PFC END,POS.PEXCH||DECODE(POS.PSUBEX,'<NULL>',''),
            POS.PCURSY,
            CASE WHEN POS.PSBCUS IS NULL THEN SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) ELSE POS.PSBCUS || SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) END ,
            NVL(POS.PSUBTY,'F') ,POS.PSTRIK,*SUM(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) ,SUM(DECODE(POS.PBS,2,ABS(POS.PPRTQ),0))* ,
            POS.PCLOSE,SUM(POS.PMKVAL) ,
            TO_CHAR(CASE WHEN INSTR(POS.PUNDCP,'.') > 0 OR LENGTH(POS.PUNDCP) < 15 THEN POS.PUNDCP ELSE TO_CHAR(TO_NUMBER(POS.PUNDCP) / 100000000) END),
            POS.UBS_ID,POS.BBG_EXCHANGE_CODE,POS.BBG_TICKER ,POS.BBG_YELLOW_KEY,POS.PPCNTY,POS.PMULTF,TO_CHAR(POS.BUSINESS_DATE,'YYYYMMDD'),
            POS.SOURCE_GMI_LIB,
            --DECODE(POS.SYSTEMCODE,'GMI1','euro','GMI2','namr','GMI3','aust','GMI4','asia','POWERBASE','aust','SINACOR','namr',POS.SYSTEMCODE),
            DECODE(p_reportid,'RVPOS_SING','euro','RVPOS_AUSTDOM','aust','RVPOS_AUSTEOD','euro','RVPOS_GLBLAPAC','asia','POS_RV_SN','namr','POS_PB','aust',POS.SYSTEMCODE),
            POS.RIC,
            CASE WHEN PSUBTY = 'S' THEN POS.TYPE ELSE NULL END,
            DECODE(POS.UBS_ID,NULL,POS.PCUSP2,POS.ISIN),POS.UNDERLYING_BBG_TICKER,POS.UNDERLYING_BBG_EXCHANGE,POS.PRODUCT_CLASSIFICATION,
            CASE WHEN PSUBTY = 'S' THEN POS.PSDSC2 ELSE NULL END,
            CASE WHEN PSUBTY = 'S' THEN C.SSDSC3 ELSE NULL END,
            NVL(C.SSECID,POS.PCUSIP),
            NULL,
            POS.PYSTMV,
            POS.PMINIT,
            POS.PEXPDT,
            CASE WHEN POS.PSUBTY='S' THEN  SUBSTR(C.ZDATA2,77,1) ELSE NULL END,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL
            FROM POSITIONS_WRK POS LEFT OUTER JOIN
            (SELECT * FROM CDS_PRODUCTS CP INNER JOIN FUTURE_MASTER FM ON
            (CP.STRXCH=FM.ZEXCH AND CP.SFC=FM.ZFC AND CP.BUSINESS_DATE = FM.BUSINESS_DATE )) C ON POS.PCUSIP = C.SCUSIP
            AND NVL(POS.PCUSP2,'X') = NVL(C.SCUSP2,'X')
            WHERE
            POS.PEXCH NOT IN ('A1','A2','A3','B1','B3','C2','D1','H1','K1','L1','M1','M3','P1','S1')
            AND (POS.PSBCUS IS NOT NULL OR POS.PCTYM IS NOT NULL OR POS.PSTYPE ='S')
            AND POS.BUSINESS_DATE = run_date_char
            GROUP BY
            POS.UBS_ID,POS.SYSTEMCODE,POS.RECIPIENTCODE,POS.BUSINESS_DATE,POS.PACCT,POS.PFIRM,POS.POFFIC,POS.PCUSIP,POS.PBS,CASE WHEN POS.PSTYPE='S' THEN POS.PSYMBL ELSE POS.PFC END,
            POS.PEXCH,POS.PSUBEX,POS.PCURSY,
            CASE WHEN POS.PSBCUS IS NULL THEN SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) ELSE POS.PSBCUS || SUBSTR(POS.PCTYM,5,2)  || SUBSTR(POS.PCTYM,1,4) END,
            NVL(POS.PSUBTY,'F') ,POS.PSTRIK,POS.PCLOSE,TO_CHAR(CASE WHEN INSTR(POS.PUNDCP,'.') > 0 OR LENGTH(POS.PUNDCP) < 15 THEN POS.PUNDCP ELSE TO_CHAR(TO_NUMBER(POS.PUNDCP) / 100000000) END),
            POS.BBG_EXCHANGE_CODE,POS.BBG_TICKER,POS.BBG_YELLOW_KEY,POS.PPCNTY,POS.PMULTF,POS.PSUBTY,POS.SOURCE_GMI_LIB,RIC,
            CASE WHEN PSUBTY = 'S' THEN POS.TYPE ELSE NULL END,
            DECODE(POS.UBS_ID,NULL,POS.PCUSP2,POS.ISIN),POS.UNDERLYING_BBG_TICKER,POS.UNDERLYING_BBG_EXCHANGE,POS.PRODUCT_CLASSIFICATION,
            CASE WHEN PSUBTY = 'S' THEN POS.PSDSC2 ELSE NULL END,
            CASE WHEN PSUBTY = 'S' THEN C.SSDSC3 ELSE NULL END,
            NVL(C.SSECID,POS.PCUSIP),
            POS.PYSTMV,
            POS.PMINIT,
            POS.PEXPDT,
            CASE WHEN PSUBTY = 'S'  THEN  SUBSTR(C.ZDATA2,77,1) ELSE NULL END;Now, could you plz help me in replacing the bold text in the query with the requirement.
    Thanks and Rgds
    DG
    Edited by: BluShadow on 16-May-2011 09:39
    added {noformat}{noformat} tags.  Please read: {message:id=9360002} for details on how to post code/data                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • CreateNativeQuery using parameter in select LIKE statement

    Can I use setParameter on native query (createNativeQuery) using LIKE in select statement?
    I have the following code and it doesn't work:
    Query qry = manager.createNativeQuery("Select * from Type as t where t.typeid LIKE '%?1%'", Type.class);
    qry.setParameter(1, "2");
    Thanks.

    You could do this using the CONCAT function (+ ||, depending on the database). i.e. concat '%' + ?1 + '%'. You can do this in a native query, but JPQL does not allow functions in like (although some providers may support it). If your using TopLink Essentials or (TopLink/EclipseLink) you can do this using an Expression query.
    But, in general it may be better and easier to just concat "%" to your argument.
    -- James : [http://www.eclipselink.org]

  • Problem in using Field Symbols in HIDE statement

    Hi All,
    I am working in an Upgrade project ( from 4.6B to ECC 5.0 ). In a program I found few warnings on HIDE statement because they have used Field Symbols in HIDE statement.
    The warning is " HIDE on a field symbol is dangerous, but the formal parameter "" is not ".
    and the piece of code is
    SET EXTENDED CHECK OFF.
    HIDE: flg_pick_up, <s1>, <s2>, <s3>, <s4>, <s5>, z_feld_ind.
    CLEAR flg_pick_up.
    SET EXTENDED CHECK ON.
    all the field symbols are of type ANY. SO can any one help in removing those warnings.
    Please reply me as soon as possible.
    With Regards,
    Amarnath Singanamala

    Hi amarnath,
    1. Why do u want to remove
       the warning ?
    2. This warning (and not an error)
       is a GENUINE warning,
      which the system wants the user to make aware of.
    3. By doing some xyz,
      even if u may be able to hide the warning,
      the warning may be hidden (for display purpose only),
      but,
      the warning will still be there inside the system.
    4. I think u should ignore the warning,
      (if there are no other repurcussions).
    regards,
    amit m.

  • Using CASE in the join statement in the AND clause. Where's the problem?

    All,
    I have my code, where based on the case statement, I would like to restrict the number of records in my JOIN condition. It's the CASE statement that I have used, that's giving me the problem. Not sure, what the problem is. The error says (in my case expression):
    Msg 102, Level 15, State 1, Line 59
    Incorrect syntax near '>'.
    Select a.Col1, a.Col2, b.Col1, b.Col2, b.Col3
    From Table1 a
    Join Table2 b
    On a.id = b.id
    Join Table3 c
    On c.FiltId = a.FiltId
    And
    Case
    When b.Col3 <> 5 --b.Col3 is an INT field
    Then (b.OutDate >= DATEADD(DAY, -30, c.InsertDate) And b.OutDate <= DATEADD(DAY, 30, c.InsertDate))
    When b.Col3 = 5
    Then (b.InDate >= DATEADD(DAY, 5, c.InsertDate))
    End
    Join Table 4 -- Other Join conditions and where clause conditions

    You do not know the CASE is an expression and fields are not columns. This is fundamental and probably means that a lot of your code needs work. 
    You can probably re-write the query with something like this: 
    SELECT A.col1, A.col2, B.col1, B.col2, B.col3
      FROM Table_1 AS A, Table_2 AS B, Table_3 AS C
     WHERE A.generic_id = B.generic_id
       AND C.foobar_id = A.foobar_id
       AND CASE
           WHEN B.col3 <> 5 
                AND (B.something_out_date 
                     <= DATEADD(DAY, -30, C.something_insertion_date) 
           THEN 'T'
           WHEN B.col3 = 5 
                AND (B.something_out_date 
                    >= DATEADD(DAY, -30, C.something_insertion_date) 
           THEN 'T'
           ELSE 'F' END = 'T' ;
    --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

  • Problem in using formula when key figure is commulative

    Hi all ,
    I am problem in generating the report when we use the  of cummulative key figure to the formula..
    consider the following senerio..
    Date      KF1 KF2 KF1(C) Kf2(C) Formula (KF1(C) - KF2(C)
    5.10.2005 1   2   1       2      -1 (wrong result)
    6.10.2005 3   4   4(1+3)  6      -1
    7.10.2005 5   6   9(4+5)  12     -1
    System is taking the actual KF1data is subtracted with KF2 data it not taking cummulative data, Actually my requirement i want to subract the cummulative data between two key figure (ie KF1(c)-KF2(c))
    My Required Output:
    Date      KF1 KF2 KF1(C) Kf2(C) Formula (KF1(C) - KF2(C)
    5.10.2005 1   2   1       2            -1 (Correct)
    6.10.2005 3   4   4(1+3)  6            -2 (4-6)
    7.10.2005 5   6   9(4+5)  12           -3 (9-12)
    pls let through the lights on the above issues.
    with Regards,
    Hari

    Hi Murali..
    Thanks a lot, now i got a proper output and working fine..
    what i did yesterday was i have creted a two key figure as a cummulative key figure ..
    and when i try to subtract two cummulative key figure system is subtracting with actual key figure and hence i got wrong result.
    Today i did same thing, only diffence is i made the third formula key figure as cummulative ..
    With regarsds,
    Hari

  • Select Join problem

    Hi Experts,
          I need your help on this.  I really don't know what's wrong with my select statment.  Please let me know what went wrong.  I'm not sure if select join statement allows parameters for select-options.  Below is my select statement.  Thanks.
      SELECT tbtcojobname tbtcplistident
             INTO CORRESPONDING FIELDS OF TABLE itab
        FROM tbtco JOIN TBTCP ON ( tbtcojobcount = tbtcpjobcount )
        WHERE tbtco~status = 'F'
          AND tbtco~jobname IN P_SEARCH
          AND tbtco~enddate IN p_date
          AND tbtcp~listident IN p_spool.
      IF sy-subrc = 0.
        APPEND itab.
        CLEAR itab.
      ENDIF.
    Anna

    Just to give you an idea:  Here's what I did.
    SELECT-OPTIONS: p_search FOR TBTCO-jobname,
                    p_date FOR TBTCO-enddate,
                    p_spool FOR TBTCP-listident.
    DATA: BEGIN OF itab OCCURS 0,
            sp_name TYPE tbtco-jobname,
            br_code(1),
            dumon(7),
            sp_numb TYPE TSP01-rqident,
            ofc(12),
          END OF itab.
    SELECT tbtcojobname tbtcplistident
             INTO CORRESPONDING FIELDS OF TABLE itab
        FROM tbtco JOIN TBTCP ON ( tbtcojobcount = tbtcpjobcount )
        WHERE tbtco~status = 'F'
          AND tbtco~jobname IN P_SEARCH
          AND tbtco~enddate IN p_date
          AND tbtcp~listident IN p_spool.
      IF sy-subrc = 0.
        APPEND itab.
        CLEAR itab.
      ENDIF.

  • Regarding select join query

    hey guys,
    I have below inputs for the screen
          ZWADAT_IST -Actual goods movement date
          ZKUNNR- shipto party
          ZVGBEL-
          ZVBELN-
          ZPOSNR-
          ZBUNKATU-
    Depends on the input, i have to retrieve necessary fields from various related tables and display in screen .
    ZSDTB_LOT is the add on table where we can access few fields as below. Now i want to write QUERY using join to fetch the fields from different tables like LIKP,LIPS,ZSDTB_LOT,ADRC according to the inputs
    and display in table control.
    I am not good in writing SELECT JOIN statement to retrieve fields in effecient way. could somebody help me
    giving equavalent code for this...
    <b>
    Select
          LIKP-WADAT_IST,
          LIKP-VSTEL(shipping point)
          LIKP-KUNNR
          LIKP-LFART(delievery type)
          LIPS-VKBUR
          LIPS-MATNR
          LIPS-VGBEL
          ZSDTB_LOT-VBELN
          ZSDTB_LOT-BUNKATSU
          ZSDTB_LOT-POSNR
          ZSDTB_LOT-LOTB
          ZSDTB_LOT-LGMNG
          ADRC-NAME1
    FROM ZSDTB_LOT,LIKP,LIPS,ADRC
    WHERE WADAT_IST IN ZWADAT_IST AND
          KUNNR IN ZKUNNR AND
          VGBEL IN ZVGBEL AND
          VBELN IN ZVBELN AND
          POSNR IN ZPOSNR AND
          BUNKATU IN ZBUNKATU.</b>
    ambichan.

    I will try to avoid a big join on so many tables. Instead I will do something like this.
    DATA: BEGIN OF deliveries OCCURS 0,
            vbeln     LIKE likp-vbeln,
            lfart     LIKE likp-lfart,
            wadat_1st LIKE likp-wadat_1st,
            vstel     LIKE likp-vstel,
            kunnr     LIKE likp-kunnr,
            posnr     LIKE lips-posnr,
            matnr     LIKE lips-matnr,
            vkbur     LIKE lips-vkbur,
            vgbel     LIKE lips-vgbel.
    DATA: END OF deliveries.
    DATA: BEGIN OF ztab_entries OCCURS 0,
            vbeln    LIKE zsdtb_lot-vbeln,
            posnr    LIKE zsdtb_lot-posnr,
            lotb     LIKE zsdtb_lot-lotb,
            lgmng    LIKE zsdtb_lot-lgmng,
            bunkatsu LIKE zsdtb_lot-bunkatsu.
    DATA: END OF ztab_entries.
    SELECT likp~vbeln likp~lfart likp~wadat_1st
           likp~vstel likp~kunnr lips~posnr
           lips~matnr lips~vkbur lips~vgbel
      FROM likp as likp INNER JOIN lips as lips
        ON likp~vbeln = lips~vbeln
      INTO TABLE deliveries
    WHERE lips~vbeln IN zvbeln
       AND lips~posnr IN zposnr.
    IF NOT deliveries[] IS INITIAL.
      DELETE deliveries WHERE NOT
            ( wadat_1st IN zwadat_1st AND
              kunnr     IN zkunnr     AND
              vgbel     IN zvgbel ).
    ENDIF.
    SELECT vbeln posnr lotb
           lgmng bunkatsu
      FROM zsdtb_lot FOR ALL ENTRIES IN deliveries
      INTO TABLE ztab_entries
    WHERE vbeln = deliveries-vbeln
       AND posnr = deliveries-posnr.
    IF NOT ztab_entries[] IS INITIAL.
      DELETE ztab_entries WHERE NOT bunkatu IN zbunkatu.
    ENDIF.
    *-- Once we have these two internal tables then we can
    *   prepare the final table by looping through them
    SORT deliveries BY vbeln posnr.
    SORT ztab_entries BY vbeln posnr.
    LOOP AT deliveries.
      CLEAR ztab_entries.
      READ TABLE ztab_entries WITH KEY vbeln = deliveries-vbeln
                                       posnr = deliveries-vbeln
                            BIANRY SEARCH.
      SELECT SINGLE name1 INTO final_tab-name1
                          FROM KNA1
                         WHERE kunnr = deliveries-kunnr.
      MOVE-CORRESPONDING: deliveries   TO final_tab,
                          ztab_entries TO final_tab.
      APPEND final_tab.
      CLEAR final_tab.
    ENDLOOP.
    This way you will be selecting records from the database with the index of the primary key and then you can manipulate the selected entries as you wish.
    Hope this helps,
    Srinivas

  • Can I answer this inqury using minus or not in statement?

    Hi everyone,
    I'm trying to solve a inquery, here's the ERP [http://www.flickr.com/photos/78615233@N04/7201804950/]
    and here's the relational schema
    CRUISE
    CRUISEID CHAR (6 BYTE)
    * CRUISE_DEPT DATE
    * CRUISE_RETURN DATE
    * CRUISE_PAY NUMBER (6,2)
    * CRUISE_DIR VARCHAR2 (10 BYTE)
    PASSENGER
    PASSID CHAR (6 BYTE)
    * PASS_LN VARCHAR2 (20 BYTE)
    * PASS_FN VARCHAR2 (20 BYTE)
    * PASS_ADD VARCHAR2 (20 BYTE)
    * PASS_DOB DATE
    * PASS_EMG_CONTACT NUMBER (10)
    NATIONALITY VARCHAR2 (20 BYTE)
    PASSID_PK (PASSID)
    TRAVEL
    PF* CRUISEID CHAR (6 BYTE)
    PF* PASSID CHAR (6 BYTE)
    CABIN_NO NUMBER (2)
    * FARE NUMBER (5,2)
    * RATING NUMBER (2)
    TRAVEL_PK (CRUISEID, PASSID)
    CABIN_NO_UN (CABIN_NO)
    TOUR_PARTICIPANT (TAKETOURS IN ERP)
    PF* CRUISEID CHAR (6 BYTE)
    PF* PASSID CHAR (6 BYTE)
    PF* TOURID CHAR (6 BYTE)
    TIP_GIVEN CHAR (1 BYTE)
    TOUR_PARTICIPANT_PK (CRUISEID, PASSID, TOURID)
    TOUR
    P * TOURID CHAR (6 BYTE)
    U TOUR_NAME VARCHAR2 (10 BYTE)
    TOUR_DURATION VARCHAR2 (7 BYTE)
    * TOUR_PRICE NUMBER (5,2)
    * TOUR_DATE DATE
    F PORTID CHAR (4 BYTE)
    F GUIDEID CHAR (5 BYTE)
    TOURID_PK (TOURID)
    TOUR_NAME_UN (TOUR_NAME)
    The question here is to List the details of all the tours for cruise number 373 that did not attract any passengers in 2011.
    I was trying to solve this problem by using MINUS or NOT IN statement, but none of them worked, so can you please help me? Thanks a lot.
    PS: Do I need to post all the CREAT TABLE and INSERT VALUE queries?

    the posting all the CREATE TABLE and INSERT's are helpful...
    -- List the details of all the tours for cruise number 373 in 2011
    select t.*
    from TRAVEL tr, TOUR t
    where
    tr.TOURID  = t.TOURID
    and CRUISEID = 373
    and to_char (TOUR_DATE ,'YYYY') = '2011'
    -- List passengers of all the tours for cruise number 373 in 2011
        select *
        from TOUR_PARTICIPANT p
        where p.CRUISEID  = tr.CRUISEID -- =373
        and p.TOURID = t.TOURID -- Tours for CRUISEID = 373 in year 2011
    -- If exist tour for CRUISEID = 373 in year 2011 and not exists passengers [PASSID] then:
    select t.*
    from TRAVEL tr, TOUR t -- (List the details of all the tours for cruise number 373 in 2011)
    where
    tr.TOURID  = t.TOURID
    and CRUISEID = 373
    and to_char (TOUR_DATE ,'YYYY') = '2011'
    and not exists -- (List passengers of all the tours for cruise number 373 in 2011)
        select 1
        from TOUR_PARTICIPANT p
        where p.CRUISEID  = tr.CRUISEID
        and p.TOURID = t.TOURID
        )

  • Using select * in a join statement

    Ok Wizards,
    If I use this code: (select * from tablea a, tableb b where a.index = b.index) joined, I can reference any column in either table using joined.column except a column named in both tables. If both tables contained a columnxyz, any reference to joined.columnxyz returns an error. Must be a naming convention this newbie is unaware of (among many other things). Your wisdom and patience are greatly admired.

    You are right SomeoneElse,
    Natural join doesn't necessarily apply unless you're using stricts naming conventions.
    You could use following syntax:
    select * from scott.emp join scott.dept on emp.deptno = dept.deptno;
    But we're back to the beginning, i.e we can't referefence deptno - it gives an error as in
    select deptno from (
    select * from scott.emp join scott.dept on emp.deptno = dept.deptno
    So forget about my second sugestion
    You could always create a view on the 2 tables joined together if you absolutely want to use *.
    Regards,

  • How can i use index in select query.. facing problem with the select query.

    Hi Friends,
    I am facing a serious problem in one of the select query. It is taking a lot of time to fetch data in Production Scenario.
    Here is the query:
      SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelat LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelatrprctr
        WHERE rldnr  = c_telstra_accounting
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          And rzzlstar in r_lstar                            
          AND rpmax  = c_max_period.
    There are 5 indices present for Table ZTFTELAT.
    Indices of ZTFTELAT:
      Name   Description                                               
      0        Primary key( RCLNT,RLDNR,RRCTY,RVERS,RYEAR,ROBJNR,SOBJNR,RTCUR,RUNIT,DRCRK,RPMAX)                                          
      005    Profit (RCLNT,RPRCTR)
      1        Ledger, company code, account (RLDNR,RBUKRS, RACCT)                                
      2        Ledger, company code, cost center (RLDNR, RBUKRS,RCNTR)                           
      3        Account, cost center (RACCT,RCNTR)                                        
      4        RCLNT/RLDNR/RRCTY/RVERS/RYEAR/RZZAUFNR                        
      Z01    Activity Type, Account (RZZLSTAR,RACCT)                                        
      Z02    RYEAR-RBUKRS- RZZZBER-RLDNR       
    Can anyone help me out why it is taking so much time and how we can reduce it ? and also tell me if I want to use index number 1 then how can I use?
    Thanks in advance.

    Hi Shiva,
    I am using two more select queries with the same manner ....
    here are the other two select query :
    ***************1************************
    SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelpt LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelptrprctr
        WHERE rldnr  = c_telstra_projects
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          and rzzlstar in r_lstar             
          AND rpmax  = c_max_period.
    and the second one is
    *************************2************************
      SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelnt LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelntrprctr
        WHERE rldnr  = c_telstra_networks
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          and rzzlstar in r_lstar                              
          AND rpmax  = c_max_period.
    for both the above table program is taking very less time .... although both the table used in above queries have similar amount of data. And i can not remove the APPENDING CORRESPONDING. because i have to append the data after fetching from the tables.  if i will not use it will delete all the data fetched earlier.
    Thanks on advanced......
    Sourabh

  • Using offset in join statement

    hi,
    i wanted to use offset in join statement. but it is giving error.
    select a~kunnr
              a~vkorg
             from knvv as inner join zcust
             on knvv-kunnr+5(5) = zcust-refid.

    hi neha,
    try this code i tested it.
    types: begin of ty_knvv,
           INCLUDE type knvv,
           kunid type i, " For u type is zcust-refid
           end of ty_knvv.
    data: it_knvv type STANDARD TABLE OF ty_knvv INITIAL SIZE 0,
          wa_knvv type ty_knvv.
    select *
      from knvv
        into table it_knvv.
    loop at it_knvv into wa_knvv.
      kunid = wa_knvv-kunnr+5(5).
      wa_knvv-kunid = kunid.
      MOdify it_knvv TRANSPORTING kunid.
      read table zcust into wa_zcust with key resid = wa_knvv-kunid.
    endloop.

  • Problem in using JOIN in code

    Hello ,
    there is one problem while using this select query :
    SELECT  a~vbeln vkorg audat auart a~netwr werks mwsbp INTO
                                           TABLE int_vbak
                                           FROM vbak AS a JOIN vbap AS b
                                           ON a~vbeln = b~vbeln
                                           FOR ALL ENTRIES IN int_auart
                                           WHERE auart EQ int_auart-low
                                           AND   vkorg IN s_vkorg
                                           AND   audat IN s_audat
                                           AND   werks IN s_werks
                                           AND   abgru EQ ' '.
    In VBAP table i have 10 records for particular vbeln but i am getting 9 only what could be the problem
    i have come across a scenerio when my vbeln and netwr are same at tht time it misses one record .
    Please help me to solve this issue so that i could get all the 10 records .
    Thanks Aryan

    Dear Aryan,
    SELECT  avbeln vkorg audat auart anetwr werks mwsbp INTO
                                           TABLE int_vbak
                                           FROM vbak AS a JOIN vbap AS b
                                           ON avbeln = bvbeln
                                           FOR ALL ENTRIES IN int_auart
                                           WHERE auart EQ int_auart-low
                                           AND   vkorg IN s_vkorg
                                           AND   audat IN s_audat
                                           AND   werks IN s_werks
                                           AND   abgru EQ ' '.
    In your code jsut check entries in for all entries table and values in the fields which you have used in your where condition.
    Hope this will help you to resolve your problem.
    Regards,
    Vijay

  • Problem in Submit via selection screen statement

    Dear Experts,
    I have designed selection screen and a dialog screen 100. I am passing the selection screen values to dialog screen using Selection screen via selection screen statement. When i tried to change the values in dialog screen, it is not allowing me to do so and the values are not refreshed.
    I have searched the SDN Forum, but not able to find the suitable thread.
    Regards,
    Ramesh Manoharan
    Edited by: ramesh.manoharan on Mar 17, 2010 1:03 PM

    Hi,
    I have used the below statement to pass values the values from selection screen to dialog screen (Created as an Executable program)
    Submit <pgm> via selection screen
      with ...... .
    Dialog screen is created as an executable program where i have created two subscreen area and populating the Selection Screen as subscreen by using the below statement:
    selection-screen begin of screen <subscreen no.> as subscreen.
    selection-screen end of screen <subscreen no.>.
    The problem i am facing is that the values of selection screen are getting populated in the dialog screen. But when i tried to change the input values in the dialog selection screen. I am unable to do that and it is not showing the new entered values. Only the previous values are shown (got from selection screen from Submit via selection screen statement).
    Kindly let me know where i am going wrong ? Kindly help me to overcome the problem .
    Regards,
    Ramesh Manoharan

  • Using SELECT INTO statement to transfer data from one DB to another?

    Hello,
    I need to move data from an SAP table to another downstream SQL server box without flat file in between. I have set up the DBCON interface, so that my ABAP code on SAP can connect to the remote SQL Server, then I can run INSERT command as Native SQL inside the ABAP.
    However, INSERT has performance problem. The best performer as I can find is SELECT INTO statement. But then I am stuck at how to use SELECT INTO to query my local SAP table and send (via INTO) to remote database. I am not even sure whether I should use Open SQL or Native SQL.
    Any suggestion? BTW, I understand the limitation of Native SQL, but we are OK to use it.
    Thanks!

    It appears that this is some kind of migration project due to the scope of the data contained in the single file? If so whatever you do is like ly to be trow away once the migration of data is completed.
    You have a couple of options:
    1) Get the data extracted from HFM in multiple files instead of one bulk file, broken down by scanario,year & period
    2) Take the single data dump file produced by FDM and manipulate it yourself to get the data in a more usuable format for processing through FDM.
    Option 2 could be achieved via any ETL tool or a custom file parsing script. What may be more attractive to you and allow you to fully leverage your investment in FDM is that you could use the PULL adapter that ships as part of the FDM adapter suite to perform this transformation exercise. The PULL adapter takes a flat file input and allows you to use all the in built functionality of FDM to transform it and output a modified flat file (or series of flat files). You could use it to produce multioload files or a series of files broken down by scenario,year,period.
    Whatever you do I would suggest that break the single data file down into smaller chunks as this will help with the iterative debugging process you will inevitably have to undetake whislt migrating the data to the new application.

Maybe you are looking for

  • Battery doesn't charge but ibook still runs on ac?

    I've got a 2004 iBook G4 1.0ghz processor 1.25gb ram. Had it 16 months, no problems so far until today. When I plug in the AC the laptop runs off this power- the battery symbol changes to show the power plugs- but the battery does not charge. It stay

  • How do I view Canon 5DIII RAW in CS3?

    Apparently I'll need to update somehow in order to work with these files.  I'm coming from a 5D1 and now have a 5DIII but can't "see" the RAW files in Photoshop or Bridge CS3.

  • Album "Edit" function can't be configured to write photos on SD card

    Edit function of Album application, as well as other edition applications (Speedseed, etc.) can't be configured to use SD card, and write editing results into internal memory.

  • Recommendations for a SILENT laptop?

    Hi, I don't know if I'm in the right place to ask something like that, but I'm planing to buy a new laptop.  The actual one's is in a bad state: hardware problems, overheating (even with frequency scaling), ultra-noisy fan, etc.  This is specially th

  • Why cant DW CS5.5 show html5's new elements in the wysiwyg design view?

    Why cant DW CS5.5 show html5's new elements in the wysiwyg design view? I created a <section> and an <aside> in code view, and styled those elements in my CSS, but it doesnt show anything in design view! why not? Its annoying. CS5.5 is Adobe's spring