Select Query with Sub

The following query gives me a syntax error using Access 2013
SELECT a.DATEa, c.TotalHours
from tblEightToNine a
where a.DATEa  EXISTS IN
  (SELECT b.Datea,Count(b.AGENT) as TotalHours
   From tblEightToNine b
   where a.DATEa = b.DATEa)
GROUP BY a.DATEa
Syntax error in query expression a.DATEA Exists IN (Select b.Datea, Count(b.AGENT) as TotalHours From tblEightToNine b where a.DATEa = b.DATEA)

Hi,
Please try Maurice's suggestion first, and see the article about the SELECT Statement of Access SQL syntax.
http://msdn.microsoft.com/en-us/library/office/ff821148(v=office.15).aspx
If you have further question about the Access SQL, please post your question to the MSDN forum for Access
http://social.msdn.microsoft.com/Forums/en-US/home?forum=accessdev&filter=alltypes&sort=lastpostdesc
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
George Zhao
TechNet Community Support
It's recommended to download and install
Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
programs.

Similar Messages

  • Query with sub functions

    Hi Experts,
    I have tried the below query with sub select function. could any one help me to fix this ?
    SELECT T0.[ItemCode], T0.[Dscription], T1.[OnHand],
    (Select distinct sum(T0.InQty) from OINM where T0.ItemCode = OINM.ItemCode and T0.DocDate = '2012/08/18' ) as 'OB Stock'
    FROM OINM T0  INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode
    WHERE T1.[OnHand] > 0   GROUP BY T0.[ItemCode], T0.[Dscription],  T1.[OnHand]
    thanks in advance,
    Regards,
    Dwarak

    Hi,
    This is for your Query.
    SELECT T0.[ItemCode], T0.[Dscription], T1.[OnHand],
    (Select distinct sum(T0.InQty) from OINM t0 where T0.ItemCode = T0.ItemCode and T0.DocDate = '2012/08/18'  ) as 'OB Stock'
    FROM OINM T0  INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode
    WHERE T1.[OnHand] > 0   GROUP BY T0.[ItemCode], T0.[Dscription],  T1.[OnHand]
    Regards,
    Kalaiyarasan.v

  • Issue in select query with where clause

    Hi guys,
    I'm facing an issue while using select query with the where clause. When I'm selecting all the data from the table it returns the correct result. But when I'm using the where clause to get the specific rows from the table it returns no rows. But the data I'm trying to fetch using the where condition exists in the table.
    Here is my query which causing the issue,
    select * from mytable where myfield = 'myvalue'
    But if I use the following query it returns the result correctly.
    select * from mytable
    Also the myfield value 'myvalue' exists in the table.
    I have tried by running this query in both SQL Developer and SQL Plus. I have tried this query in mssql as well. It works perfectly and returns correct result sets for both the queries I have mentioned above. I'm unable to predict the issue as I'm new to ORACLE. Please help.
    Thanks,
    Ram.

    Hi Ram,
    I experienced an issue similar to this with a varchar2 field. Some of our records had a hidden newline character at the end of them, which was making queries like the one below fail:
    select * from employees
    where email = '[email protected]'The best way I found to detect this was to use
    select 'XX'||email||'XX' from employeesTo make sure that there were no newlines. But that is just a guess. If you could provide some example table data and the outputs of your selects, it would be helpful.
    Jeff

  • How to write XSJS Select Query with input parameters

    Hello Experts,
    I am creating a xsjs file and in that file I am trying to write a Select Query based on a Calculation View
    I have tried it the following way:
    var query = 'SELECT TOP 100 \"Name\", \"Address\", \"City\", \"Country\" FROM \"_SYS_BIC\".\"Test.HL/AddressView\"'
        + 'WITH PARAMETERS(\'PLACEHOLDER\' = (\'$$P_Name$$\', \' Akhil \'),'
      + '\'PLACEHOLDER\' = (\'$$P_City$$\', \' Lucknow \'))';
    But it gives me the "Mixed spaces and tabs error".
    How should I write XSJS Select Query with input parameters?
    Regards,
    Rohit

    >But it gives me the "Mixed spaces and tabs error".
    Mixed spaces and tabs has nothing to do with the syntax of the statement. You used both spaces and the tab in the content - which JSLint doesn't like.  Remove the beginning spaces of each line and use only one or the other.
    The actual syntax of your statement doesn't look right.  The problem is that you are escaping the \ when you don't need to if you are using ' instead of " for your string.  You escape with \" in the first line but then escape with \' in the 2nd and 3rd line.  That is going to cause serious parsing problems with the command.

  • Absolute dynamic select query with dynamic join and where

    Has anyone ever tried creating an absolutely dynamic SELECT query with dynamic Join and Where conditions.
    I have a requirement of creating such a query in an Utility Class, and i have written the code. But its throwing my sysntax errors.
    Please let me know where am I going wrong OR is it really possible to create such a dynamic Query??
        SELECT (FIELDS) INTO TABLE IT_TABLES
          FROM ( (ME->TABLE1)  inner join ( me->table2 )
          on ( on_condition ) )
          WHERE (me->where_fields).
    Ags.

    It worked for me in a following way:
    select * into corresponding fields of table <result_table>
            from (join_string)
            where (l_where).
    Where the contents of join_string were dynamically build using concatenation. So it will be something like
    concatenate ME->TABLE1 'as a INNER JOIN' me->table2 'as b ON (' into join_string separated by space.
    <...>
    add here matching/reference colums, something like
    concatenate 'a~' me->TABLE1_JOIN_COL into temp1.
    concatenate 'b~' me->TABLE2_JOIN_COL into temp2.
    concatenate join_string temp1 '=' temp2 into join_string separated by space.
    <...>
    concatenate join_string ')' into join_string separated by space.
    And then use similar approach for l_where variable.

  • Dynamic select query with dynamic where condition

    Hi all,
    I want to use the dynamic select query with dynamic where condition. For that I used the below code but I am getting dump when using this code.
    Please advice, if there is any other way to achieve this requirement.
    Thanks,
    Sanket Sethi
    Code***************
    PARAMETERS: p_tabnam      TYPE tabname,
                p_selfl1      TYPE edpline,
                p_value       TYPE edpline,
                p_where1      TYPE edpline .
    DATA: lt_where    TYPE TABLE OF edpline,
          lt_sel_list TYPE TABLE OF edpline,
          l_wa_name   TYPE string,
          ls_where    TYPE edpline,
          l_having    TYPE string,
          dref        TYPE REF TO data,
          itab_type   TYPE REF TO cl_abap_tabledescr,
          struct_type TYPE REF TO cl_abap_structdescr,
          elem_type   TYPE REF TO cl_abap_elemdescr,
          comp_tab    TYPE cl_abap_structdescr=>component_table,
          comp_fld    TYPE cl_abap_structdescr=>component.
    TYPES: f_count TYPE i.
    FIELD-SYMBOLS : <lt_outtab> TYPE ANY TABLE,
    *                <ls_outtab> TYPE ANY,
                    <l_fld> TYPE ANY.
    struct_type ?= cl_abap_typedescr=>describe_by_name( p_tabnam ).
    elem_type   ?= cl_abap_elemdescr=>describe_by_name( 'F_COUNT' ).
    comp_tab = struct_type->get_components( ).
    comp_fld-name = 'F_COUNT'.
    comp_fld-type = elem_type.
    APPEND comp_fld TO comp_tab.
    struct_type = cl_abap_structdescr=>create( comp_tab ).
    itab_type   = cl_abap_tabledescr=>create( struct_type ).
    l_wa_name = 'l_WA'.
    CREATE DATA dref TYPE HANDLE itab_type.
    ASSIGN dref->* TO <lt_outtab>.
    *CREATE DATA dref TYPE HANDLE struct_type.
    *ASSIGN dref->* TO <ls_outtab>.
    * Creation of the selection fields
    APPEND p_selfl1 TO lt_sel_list.
    APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.
    ** Creation of the "where" clause
    *CONCATENATE p_selfl1 '= '' p_value ''.'
    *            INTO ls_where
    *            SEPARATED BY space.
    *APPEND ls_where TO lt_where.
    * Creation of the "where" clause
    APPEND p_where1 TO lt_where.
    * Creation of the "having" clause
    l_having = 'count(*) >= 1'.
    * THE dynamic select
    SELECT          (lt_sel_list)
           FROM     (p_tabnam)
           INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>.
    *       WHERE    (lt_where).

    Hi Sanket,
    The above given logic of mine works for you, put the code in the If condition and try-
    just like below:
    IF NOT P_EBELN IS INITIAL.
    lt_where = '& = ''&'' '.
    REPLACE '&' WITH p_ebeln INTO lt_where.
    REPLACE '&' WITH field_value INTO lt_where.
    SELECT (lt_sel_list) INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>
    FROM (p_tabnam)
    WHERE (lt_where).
    ENDIF.
    thanks\
    Mahesh

  • BDC select query with addition based on all If conditions

    Hi can any one send me the select query with conditions like
    If Itab is not initial.
    Endif. and if possible with valiadations messages also.
    IF CHECK_NUMBER of CHECK_ADVICE of the flat file = PAYR-CHECT. Then update SAP field BSEG-XREF2 .
    9.     When Flat file check Number = PAYR-CHECT then Insert or Update Flat file RECEIPT_DATE into SAP field BSEG-XREF1.
    Please send me immediately.

    >     SELECT rsnum
    >            rspos
    >            matnr
    >            werks
    >         lgort
    >            shkzg
    >            aufnr
    >            bdmng
    >            enmng                      
    >            FROM  resb INTO  TABLE it_rsnum FOR ALL ENTRIES IN it_aufnr
    >            WHERE rsnum EQ it_aufnr-rsnum
    >            AND   xloek NE 'X'
    >            AND   postp NE 'X'
    >            AND   resbbdmng GE resbenmng.
    >   ENDIF.
    >
    > Database Table RESB: 40,000,000 Records (40 Million)
    > Internal Table   it_aufnr:  20,000 Entries
    > Entries selected from RESB: 150,000.
    >
    Hi,
    the problem is the big for all entries table.
    Your 20.000 records FAE will be split into SEVERAL sql statements depending on the size of the table.
    Where do you get the it_auftrn from?
    If it's another transparent table try to JOIN this table to your big table.
    SELECT rsnum
                rspos
                matnr
                werks
            lgort
                shkzg
                aufnr
                bdmng
                enmng                      
                FROM  resb JOIN tab_auftrn  on  resbrsnum = tab_auftrnauftrn
                AND   xloek NE 'X'
                AND   postp NE 'X'
                AND   resbbdmng GE resbenmng.
    Make sure that your WHERE filter and the JOIN keys on both tables are supported by indexes.
    150.000 records about of 40 Mio. can definitly be serviced by an appropriate index:
    i.e. Index fields (check your PK or secondary indexes):
    rsnum
    enmng                      
    aufnr
    bye
    yk

  • I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year

    I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year

    Hi Arun ,
    Can you explain little bit more ??
    what is account doc no? 
    what are the transactions should be displayed in your output??
    -Rajesh N

  • How to re-write this big SELECT Query with INNER JOINs?

    Hi Experts
    I have a performance killer SELECT query with an inner join of 3 tables u2013 VBAP, VBAK and VBEP together, which populates records to an internal table INT_COLL_ORD. Based on these records selected, in another SELECT query, records are fetched from VBUK table to the internal table INT_VBUK.
    SELECT A~VBELN A~POSNR A~MATNR A~KWMENG A~KBMENG A~ERDAT A~ERZET A~PSTYV D~AUART E~ETTYP E~EDATU
    INTO TABLE INT_TAB_RES
    FROM VBAP AS A INNER JOIN VBAK AS D
    ON D~VBELN EQ A~VBELN AND D~MANDT EQ A~MANDT
    INNER JOIN VBEP AS E
    ON E~VBELN EQ A~VBELN AND E~POSNR EQ A~POSNR AND E~MANDT EQ A~MANDT
    WHERE  A~VBELN IN s_VBELN AND
           D~auart in s_auart AND
           D~vkorg in s_vkorg AND
           D~vbtyp eq 'C'     AND
           ( ( matnr LIKE c_prefix_sp AND zz_msposnr NE 0 AND kbmeng EQ 0 )
           OR ( matnr LIKE c_prefix_fp AND kwmeng NE A~kbmeng ) ) AND
           A~ABGRU EQ SPACE AND
           A~MTVFP IN R_MTVFP AND
           A~PRCTR IN R_PRCT AND
           E~ETENR EQ '1'.
    SORT INT_COLL_ORD BY VBELN POSNR ETTYP.
    DELETE ADJACENT DUPLICATES FROM INT_TAB_RES COMPARING VBELN POSNR.
    CHECK NOT INT_TAB_RES [] IS INITIAL.
    SELECT VBELN UVALL CMGST INTO TABLE INT_VBUK
    FROM VBUK FOR ALL ENTRIES IN INT_TAB_RES
    WHERE VBELN = INT_TAB_RES-VBELN AND UVALL NE 'A'.
    Now, the requirement is:
    I want to split this query. Like, first join VBAK and VBUK first. With this selection, go to the inner join of VBAP and VBEP (on key VBELN) to get the results. How can I re-write this Query?
    Please help.
    Thx n Rgds

    Hi Nagraj
    As of your suggestion, I have re-written the query as below:
    * Declarations
    TYPES: BEGIN OF TYP_COLL_ORD,
            VBELN  LIKE VBAK-VBELN,
            POSNR  LIKE VBUP-POSNR,
            MATNR  LIKE VBAP-MATNR,
            KWMENG LIKE VBAP-KWMENG,
            KBMENG LIKE VBAP-KBMENG,
            ERDAT  LIKE VBAK-ERDAT,
            ERZET  LIKE VBAK-ERZET,
            PSTYV  LIKE VBAP-PSTYV,
            AUART  LIKE VBAK-AUART, u201Calready exists in type
            ETTYP  LIKE VBEP-ETTYP,
            EDATU  LIKE VBEP-EDATU.
    TYPES: END OF TYP_COLL_ORD.
    DATA: INT_COLL_ORD TYPE TABLE OF TYP_COLL_ORD WITH HEADER LINE.
    TYPES: BEGIN OF TYP_VBUK,
            AUART  LIKE VBAK-AUART, u201Chave added this field
            VBELN  LIKE VBUK-VBELN,
            UVALL  LIKE VBUK-UVALL,
            CMGST  LIKE VBUK-CMGST.
    TYPES: END OF TYP_VBUK.
    DATA: INT_VBUK TYPE TABLE OF TYP_VBUK WITH HEADER LINE.
    *QUERY#1 u2013 for VBAK & VBUK Join
    SELECT A~AUART B~VBELN B~UVALL B~CMGST
    INTO TABLE INT_VBUK
    FROM VBAK AS A INNER JOIN VBUK AS B
    ON A~VBELN EQ B~VBELN
    WHERE A~VBELN IN s_VBELN AND
    A~auart in s_auart AND
    A~vkorg in s_vkorg AND
    A~vbtyp eq 'C' AND
    B~UVALL NE 'A'.
    IF NOT INT_VBUK[] IS INITIAL.
    SORT INT_VBUK BY VBELN.
    DELETE ADJACENT DUPLICATES FROM INT_VBUK COMPARING VBELN.
    *QUERY#2 u2013 for VBAP & VBEP Join
    SELECT A~VBELN A~POSNR A~MATNR A~KWMENG A~KBMENG A~ERDAT A~ERZET A~PSTYV B~ETTYP B~EDATU
    INTO TABLE INT_COLL_ORD
    FROM VBAP AS A INNER JOIN VBEP AS B
    ON B~VBELN EQ A~VBELN AND B~POSNR EQ A~POSNR AND B~MANDT EQ A~MANDT
    FOR ALL ENTRIES IN INT_VBUK
    WHERE A~VBELN = INT_VBUK-VBELN AND
    ( ( matnr LIKE c_prefix_sp AND zz_msposnr NE 0 AND kbmeng EQ 0 )
    OR ( matnr LIKE c_prefix_fp AND kwmeng NE A~kbmeng ) ) AND
    A~ABGRU EQ SPACE AND
    A~MTVFP IN R_MTVFP AND
    A~PRCTR IN R_PRCT AND
    B~ETENR EQ '1'.
    ENDIF.
      SORT INT_COLL_ORD BY  VBELN POSNR ETTYP.
      DELETE ADJACENT DUPLICATES FROM INT_COLL_ORD
        COMPARING VBELN POSNR.
      CHECK NOT INT_COLL_ORD[] IS INITIAL.
      LOOP AT INT_COLL_ORD.
        CLEAR: L_MTART,L_ATPPR,L_ETTYP.
        IF L_PREVIOUS_ETTYP NE INT_COLL_ORD-ETTYP OR
          L_PREVIOUS_AUART NE INT_COLL_ORD-AUART.
          READ TABLE INT_OVRCTL WITH KEY AUART = INT_COLL_ORD-AUART ETTYP = INT_COLL_ORD-ETTYP.
          CHECK SY-SUBRC NE 0.
    Now, the issue is:
    Please note that declaration for INT_COLL_ORD has a field AUART, which is used in further parts of program (see the statement just above)
    But, since neither VBAP nor VBEP contains AUART field, it cannot be fetched through the QUERY#2. So this value is not populated into INT_COLL_ORD through SELECT Query.
    Since this field is used in later part of program & that the internal table has no value for this field, it dumps!!
    How to include this value into the INT_COLL_ORD?
    Plz suggest....

  • Filter query with sub query using Dropdown box

    Dear Community,
    I have 2 queries
    1. Main Query with 2 fields:  Project | Project value
    2. Sub Query with 2 fields:  Project group | Project
    Project group can be belonging to number of projects and project can be belong to number of project group (Many to Many).
    My customer wants the main query will open without any filtering.
    When I choose project group from WAD dropdown box, the main query will filtering all the projects that belong to the project group.
    I create WAD; define dropdown box as sub query, and Analysis as main query.
    In the dropdown box I choose "data binding" char and create command "set selection state by binding" (project to project) but it doesnu2019t work. 
    I also try to do this by Replacement Path in the main query, but the variable requires the attribute will be ready for input.
    Thanks a lot
    Yaniv

    I am not sure about your comments on replacement path variable. Without having tried it, here is what I would have attempted:
    The main query needs to use a replacement path variable for Project that is replaced by the results of the sub-query. Sub-query would have a regular input variable for project group. (as a quick test, if you had one analysis item for main query with variable input enabled, it should prompt you to enter Project group).
    Now the drop-down needs to be associated with a javascript function. The javascript function needs to implement command "Set variable state" for the main query data provider to selected value of the drop-down.
    The drop-down should be associated with the sub-query data provider, just used to populate the list of values in drop-down.

  • Select query with secondary index

    hi,
    i have a report which is giving performance issues on a perticular select query on KONH table.
    the select query doesnt use the primary key fields and table already has around 19 million entries.So there was a secondary index created for the fields in the table.
    now, KONH is a client specific table, and hence has MANDT as the first field. when the table is not indexed it is sorted according to the order of fields, like first MANDT, then primary key fields and then remaining fields.. (correct me if i am wrong)
    but the secondary index created doesnt has MANDT in it..(yea, a mistake! )...
    but instead of correccting the secondary index, i am told to change the select query..
    so, i used a "client specific" syntax to sort the issue.. but i dont understand whre i should put the "where mandt eq sy-mandt" clause..
    should i put it right after all my secondary index fields are over? or what happens to the order of fields which are not present in the list of secondary index?
    kindaly help.
    thanx.

    Hi chinmay kulkarni,
    its better if you can ask concerned person to add MANDT field in your  index as well....
    Indexes and MANDT
    If a table begins with the mandt field, so should its indexes. If a table begins with mandt and an index doesn't, the optimizer might not use the index.
    Remember, if you will, Open SQL's automatic client handling feature. When select * from ztxlfa1 where land1 = 'US' is executed, the actual SQL sent to the database is select * from ztxlfa1 where mandt = sy-mandt and land1 = 'US'. Sy-mandt contains the current logon client. When you select rows from a table using Open SQL, the system automatically adds sy-mandt to the where clause, which causes only those rows pertaining to the current logon client to be found.
    When you create an index on a table containing mandt, therefore, you should also include mandt in the index. It should come first in the index, because it will always appear first in the generated SQL.
    Index: Technical key of a database table.
    Primary index: The primary index contains the key fields of the table and a pointer to the non-key fields of the table. The primary index is created automatically when the table is created in the database.
    Secondary index: Additional indexes could be created considering the most frequently accessed dimensions of the table.
    Structure of an Index
    An index can be used to speed up the selection of data records from a table.
    An index can be considered to be a copy of a database table reduced to certain fields. The data is stored in sorted form in this copy. This sorting permits fast access to the records of the table (for example using a binary search). Not all of the fields of the table are contained in the index. The index also contains a pointer from the index entry to the corresponding table entry to permit all the field contents to be read.
    When creating indexes, please note that:
    An index can only be used up to the last specified field in the selection! The fields which are specified in the WHERE clause for a large number of selections should be in the first position.
    Only those fields whose values significantly restrict the amount of data are meaningful in an index.
    When you change a data record of a table, you must adjust the index sorting. Tables whose contents are frequently changed therefore should not have too many indexes.
    Make sure that the indexes on a table are as disjunctive as possible.
    (That is they should contain as few fields in common as possible. If two indexes on a table have a large number of common fields, this could make it more difficult for the optimizer to choose the most selective index.)
    For Example...
    SELECT KUNNR KUNN2 INTO TABLE T_CUST_TERR
    FROM KNVP CLIENT SPECIFIED
    WHERE MANDT = SY-MANDT " here MANDT shd be first
    AND KUNN2 IN S_TERR
    AND PARVW LIKE 'Z%'.
    Accessing tables using Indexes
    The database optimizer decides which index on the table should be used by the database to access data records.
    You must distinguish between the primary index and secondary indexes of a table. The primary index contains the key fields of the table. The primary index is automatically created in the database when the table is activated. If a large table is frequently accessed such that it is not possible to apply primary index sorting, you should create secondary indexes for the table.
    The indexes on a table have a three-character index ID. '0' is reserved for the primary index. Customers can create their own indexes on SAP tables; their IDs must begin with Y or Z.
    If the index fields have key function, i.e. they already uniquely identify each record of the table, an index can be called a unique index. This ensures that there are no duplicate index fields in the database.
    When you define a secondary index in the ABAP Dictionary, you can specify whether it should be created on the database when it is activated. Some indexes only result in a gain in performance for certain database systems. You can therefore specify a list of database systems when you define an index. The index is then only created on the specified database systems when activated
    Also pls have a look on below link
    http://www.sapfans.com/sapfans/forum/devel/messages/30240.html
    Hope it will solve your problem..
    Reward points if useful...
    Thanks & Regards
    ilesh 24x7

  • Select query with UNION clause in database adapter

    Friends,
    I have got a SQL query with two UNION clause withing it. like
    select a,b,c
    from a
    union
    select a,b,c
    from b
    The schema generated is like below in sequence
    <element>a</element>
    <element>b</element>
    <element>c</element>
    <element>a</element>
    <element>b</element>
    <element>c</element>
    So, the columns from different select queries joined with UNION clause are all appeared in schema instead of the distinct columns.
    Is there any way around to solve this issue ? or will need to with DB function/procedure.

    I think I know what you are saying but your example doesn't make sense, your SQL should produce something like
    I had to change a, b, c with elementA, elementB, elementC as a and b are reserved html tags.
    <elementA>DateA</elementA>
    <elementB>DataB</elementB>
    <elementC>DataC</elementC>
    ...What is the result of the query when you run it in SQLPlus? Is it what you expect?
    cheers
    James

  • 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

  • Select query with package size

    Hi ,
          i am trying to use select qurey with package size , to limt the data fetching .
    Can any one gives sqample code or idea select query using 'package size'.
    Advance Thanks,
    Regards
    veera

    Hi,
        SELECT vbeln erdat
        FROM vbak
        INTO TABLE li_vbak PACKAGE SIZE 50.
         SELECT posnr matnr meins
          FROM vbap
          INTO TABLE li_vbap
          FOR ALL ENTRIES IN li_vbak
          WHERE vbeln = li_vbak-vbeln.
    Hi i want  to select only from vbeln ,ie single selct query only using pakage size.200,blocks in data base ..How ?
    Regards
    veera

  • Select-query with *

    Hi, I wish to select rows from a database. This is the query I wrote:
    "SELECT * FROM opencalls WHERE ProblemDescription LIKE '*upgrade*'".
    When I run this query in MS Access itself, there is no problem, I get the required rows. But when I run it in my program, I get no results. When I remove the *, there is no problem either in my Java program. What's the correct way to make my program interprete the *?
    Thanks, Roel

    look... i don't know why u r using the * character?? in SQL if u wanna place a one character matching u should use _ (underscore) and for more than one character matching u should use % so for example if u wanna look in a table for the matching of the word "Cookie" and u want this word to be the first word in the sentance of that field u do the following:
    SELECT * FROM table_name WHERE field_name LIKE 'Cookie%';
    this will take care of that. suppose u wanna look for sentances that have the first word as either Rook or Book then u can use that query with the Underscore as the first character:
    SELECT * FROM table_name WHERE field_name LIKE '_ook%';
    for ur case u wanna query the table for any sentences that have the word upgrade.. then u should use the following:
    SELECT * FROM opencalls WHERE ProblemDescription LIKE '%upgrade%';
    i think this will work fine...i hope this would be the solution for ur problem : )
    Khalid

Maybe you are looking for

  • OFFICEJET 6100 WILL NOT CONNECT TO WIRELESS - 10.9.4 - NO SUGGESTIONS HELP

    Tried everything and just waiting   30 minutes on chat and then got bumped off the moment the tech connect... after it said 1 minute or less... I waited another 15 minutes.... now trying to connect via chat again and now have another 28 mintues to wa

  • Issue with Packaged Jars added to project from resource Palette

    Hello! I am using Jdeveloper 11.1.2.2. I started this post thinking there was an issue having to do with packaging jars that refer to other libraries (see post Are Libraries Required? Now I realize it is a different issue (although that other post is

  • How to extract the Fast Formula Body through database?

    Hi All The Oracle fast formulas are stored in the ff_formulas_f table under the column formula_text having the datatype long. I want to extract the formula text through back end. When I use the statement, Select formula_text from ff_formulas_f, I am

  • How to refer a particular filed of a Table data type

    DECLARE           CURSOR C1 IS SELECT                                    GLUSR_USR.GLUSR_USR_ID BYER_ID,                                    GLUSR_USR.GLUSR_USR_ADD1 BUYER_ADD           FROM                GLUSR_USR           WHERE                ROWN

  • Widescreen Format custom preset in Compressor 4?

    I used to do HD (16X9) format only, but ever since I saw other views, especially really cool looking cinematic music videos carrying the widescreen format I've been wanting to apply that to my videos. Currently my only known solution to this is simpl