Doubt about Select statement.

Hi folks!!
             I have a few doubts about the select statements, it may be a silly things but its useful for me.
what is   difference between below statment.
1)SELECT * FROM TABLE.
2)SELECT SINGLE * FROM TABLE
3)SELECT SINGLE FROM TABLE.
Hope i will get answer,thanks in advance.
Regards
Richie..

Hi,
try this and if possible use sap help.i mean place the cursor on select and press F1.
             Types of select statements:
1.     select * from ztxlfa1 into table it.
             This is simple select statement to fetch all the data of db table into internal table it.
   2.   select * from ztxlfa1 into table it where lifnr between 'V2' and 'V5'.
        Thisis using where condition between v2 and v5.
  4. select * from ztxlfa1 where land1 = 'DE'. "row goes into default table work Area
  5. select lifnr land1 from ztxlfa1
        into corresponding fields of it   "notice 'table' is omitted
         where land1 = 'DE'.
          append it.
           endselect.
     Now data will go into work area. and then u will add it to internal table by     
        append statement.
  6.   Table 13.2 contains a list of the various forms of select as it is used with internal tables and their relative efficiency. They are in descending order of most-to-least efficient.
Table 13.2  Various Forms of SELECT when Filling an Internal Table
Statement(s)                                   Writes To
select into table it                                    Body
select into corresponding fields of table it   Body
select into it                                    Header line
select into corresponding fields of it           Header line
7. SELECT VBRK~VBELN
       VBRK~VKORG
       VBRK~FKDAT
       VBRK~NETWR
       VBRK~WAERK
       TVKOT~VTEXT
       T001~BUKRS
       T001~BUTXT
    INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
    FROM VBRK
    INNER JOIN TVKOT ON VBRKVKORG = TVKOTVKORG
    INNER JOIN T001 ON VBRKBUKRS = T001BUKRS
    WHERE VBELN IN DOCNUM AND VBRK~FKSTO = ''
   AND VBRK~FKDAT in date.
Select statement using inner joins for vbrk and t001 and tvkot table for this case based on the conditions
8. SELECT T001W~NAME1 INTO  TABLE IT1_T001W
FROM T001W INNER JOIN EKPO ON T001WWERKS = EKPOWERKS
WHERE EKPO~EBELN = PURORD.
here selecting a single field into table it1_t001winner join on ekpo.
9. SELECT BUKRS LIFNR EBELN FROM EKKO INTO CORRESPONDING FIELDS OF IT_EKKO WHERE     EBELN IN P_O_NO.
ENDSELECT.
SELECT BUTXT   FROM T001 INTO  IT_T001 FOR ALL ENTRIES IN IT_EKKO WHERE BUKRS = IT_EKKO-BUKRS.
ENDSELECT.
APPEND IT_T001.
here I am using for all entries statement with select statement. Both joins and for all entries used to fetch the data on condition but for all entries is the best one.
10. SELECT AVBELN BVTEXT AFKDAT CBUTXT ANETWR AWAERK INTO TABLE ITAB
             FROM  VBRK AS A
             INNER JOIN TVKOT AS B ON
             AVKORG EQ BVKORG
             INNER JOIN T001 AS C ON
             ABUKRS EQ CBUKRS
             WHERE  AVBELN IN BDOCU AND AFKSTO EQ ' ' AND B~SPRAS EQ
             SY-LANGU
             AND AFKDAT IN BDATE AND AVBELN EQ ANY ( SELECT VBELN FROM
            VBRP WHERE VBRP~MATNR EQ ITEMS ).
    Here we are using sub query in inner join specified in brackets.
Thanks,
chandu.

Similar Messages

  • Doubt on Select Statement

    HI Friends,
    i have a requirement to select matnr,werks and mmsta from marc table.where i have input of matnr and mmsta.
    The matnr in the marc table having 2 werks with different mmsta.
    i was asked to select matnr not having mmsta 40.
    but in marc table there is same matnr with two mmsta 37 and 40.
    i want a select statement which should not pick matnr having 40.
    my select statement was
    select matnr werks mmsta into itab from marc
    where matnr in fpso_matnr and mmsta in fpso_mmsta.
    this does not work for the above condition.
    please suggest me a correct statement..
    Thanks,
    Gokul

    select matnr werks mmsta into itab from marc
    where matnr in fpso_matnr and mmsta in fpso_mmsta
       and mmsta NE 40.
    ill this not work ?
    MARC is plant data.. so I guess u need to give werks also...
    Edited by: jackandjay on Dec 19, 2007 12:02 PM

  • About SELECT statement

    Hi,
    I have a table say XYZ, the only operation performed on the table is insert(no update or delete). The table can be accessed by other applications also but always read only mode.
    I'm executing a simple query
    SELECT * FROM XYZ
    Is it safe to assume that the result is always in same order (with newrecords appended at end)?
    Regards,
    Mayur.

    Hi Mayur,
    I would rather mean it is NOT safe to say that. I did some tests but cannot prove it is unsafe if the optimizer is chosing a full table scan, which is still insuffisant to say it is safe.
    If the optimizer is chosing another plan, then you may have surprises, and a newer/older oracle version/patch may produce a different plan...
    drop table t1;
    create table t1 (n1 number, n2 number primary key) organization index;
    exec for i in 1 .. 10 loop insert into t1 values (i,1001-i); end loop
    commit;
    select * from t1;
            N1         N2
            10        991
             9        992
             8        993
             7        994
             6        995
             5        996
             4        997
             3        998
             2        999
             1       1000
    10 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=2 Card=10 Bytes=260)
       1    0   INDEX (FAST FULL SCAN) OF 'SYS_IOT_TOP_40332' (INDEX (UNIQUE)) (Cost=2 Card=10 Bytes=260)Best regards
    Laurent

  • Doubt about UPDATE STAT COLUMN

    Hi,
    I have a doubt of when to execute update stat:
    i create this SQL to generate an SQL script to generate update stat for all my tables:
    select 'UPDATE STAT ' || schemaname || '.' || tablename || ' ESTIMATE SAMPLE 20 PERCENT' from tables where schemaname = 'DBUSER' and not tablename like 'JDBC%' AND type = 'TABLE'
    and created this SQL to generate an SQL script for update stat for all columns.
    select 'UPDATE STAT COLUMN(*) FOR ' || schemaname || '.' || tablename || ' ESTIMATE SAMPLE 20 PERCENT' from tables where schemaname = 'DBUSER' and not tablename like 'JDBC%' AND type = 'TABLE'
    my doubt is i really need run that second script? or the UPDATE STAT for table dont UPDATE STAT for all columns?
    thanks for any insight
    Clóvis

    > my doubt is i really need run that second script? or the UPDATE STAT for table dont UPDATE STAT for all columns?
    Hi Clovis,
    hmm... good question.
    There are a few things to know about the UPDATE STAT command here.
    1) It will always generate statistics for key or indexed columns.
    2) The optimizer won't be able to generate a better plan when there are column statistics for non-indexed columns present.
    3) The command will also collect column statistics for all columns that already have statistics.
    The direct effect of 3) is that by running your second command just once - all column statistics will always be collected.
    Since you can easily change the default sample size for your tables via
    ALTER TABLE SAMPLE SIZE 20 PERCENT
    I would say: drop your script and just use
    UPDATE STAT DBUSER.* ESTIMATE
    This single command would lead to the same statistics as your script does.
    And if you really, really want to leave out the JDBC tables - then just set their default sample size to 0 and they will be ignored by the UPDATE STAT command.
    regards,
    Lars

  • Simple doubt in select statement

    hi all,
    Although this is a very simple ques.
    Can u pl tell me why i m not getting the value into v_adrnr ?
    Chk the following code.
    V_VBELN  = '0080000001'.
      SELECT SINGLE ADRNR
             FROM VBPA
             INTO V_ADRNR
             WHERE VBELN = V_VBELN
             AND   PARVW = 'BP'.
    i have cheked the table vbpa for the above mentioned conditions.I can see the
    value for adrnr in database as 0000022741.
    But while i run the above code i cant see value on v_adrnr.
    Pl help.

    First PARVW has a domain with a conversion routine based on table TPAUM so "BP" is internal code "RE"
    Use CONVERSION_EXIT_PARVW_INPUT
    CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
      EXPORTING
        input = V_PARVW
      IMPORTING
        output = V_PARVW.
    Second
    Have you defined V_VBELN with reference to the element VBELN, char 10 with conversion Alpha
    Then it should work
    Regards

  • Doubt in select statement

    Hi :
    How can i join aufnr , arbei , ismnw since there is no common key field between arbei and aufnr , ismnw.
    I am able to join aufnr and ismnw based on aufnr, because im trying to pull data based on aufnr , but when i went to se84 and tried to chk tables for arbei...only one table HIKO has all these fields but there is no data in that.
    SELECT aaufnr aauart b~arbei INTO CORRESPONDING FIELDS OF TABLE it_tab
    FROM aufk AS a
    INNER JOIN plpo AS b ON awerks = bwerks
    INNER JOIN iloa AS d ON abukrs = dbukrs
    *06/18
    INNER JOIN afko AS e ON aaufnr = eaufnr
    WHERE a~auart IN s_auart
    AND a~auart NE 'PM04'
    AND a~auart NE 'PM09'
    AND a~werks = 'M600'
    AND d~tplnr = 'PB-PRO-S01-BY02-MIL'
    AND d~abckz IN s_abckz
    AND a~erdat IN s_date.
    SELECT SINGLE ismnw INTO v_ismnw FROM afru
    WHERE aufnr = v_aufnr.
    it_tab-ismnw = v_ismnw.
    with my first select statment do i get unique values for arbei?
    i would appreciate if any one can help me on this.
    Thanks.
    Raghu

    Everybody's question is important.
    All you have to do is edit your original question and it will pop to the top.
    If you ask the same question twice, somebody may spend a lot of time trying to answer your question only to find that someone else answered it a long time before.
    Rob

  • Hi friends i have doubt on select statement

    hi friends, i am using one ztable which contains around 60 fields. i would like to consider in to itab around 52 fields. for this i am using "select * from ztable into itab....". can u please suggest me how can i improve by selecting all the fields and without reducing performance.

    Declare as below:
    Select-options: s_matnr FOR mara-matnr.
    Data: Begin of itab.
      INCLUDE STRUCTURE mara.
    Data: End of itab.
    Clear itab.
    Refresh itab.
    Select * from mara
             into table itab
             where matnr = s_matnr.
    if sy-subrc = 0.
    SORT itab.
    endif.
    OR if you are selecting based on some internal table then use
    FO ALL ENTRIES IN itab1.
    Hope this helps you, it will also improve your performance.
    Reward points and close the thread else revert back.

  • Doubt about select performance and keys in Select.

    Hi Gurus.
    I need select data from VBAK with key Vbeln (VBFA has value then i can use your vbelv i think)  then with VBAK-BSTNK and VBAK-KUNNR i goin to select data from KNA1 , only field ADRNR , then i going to ADRC table with field ADRNR  like key, then i could select CITY1, STREET, HOUSE_NUM1, HOUSE_NUM2, CITY2, POST_CODE1 e CITY1.
    1- I know that tables has many data then i need advices for a good performance. suggests is welcome.
    2- If i write any thing wrong please tell me .
    3-If anybody know any key that i don´t write please tell me.
    4-If anybody know other way .suggests is welcome.
    Thanks comunitty for help.

    Hi Ronaldo,
    It seems you have everything you need. You have primary keys for VBAK, KNA1 and ADRC, so the best option in my opinion is one select from vbak inner join KNA1. As fopr ADRC it may be tricy because of the date from / to, so this might be worth going FAE. But test both posibilities before settling for one.  I don't know why you need BSTNK though
    By the way, this I assume you are writing a report? cause if you only need one record at a time I suggest you use BAPIs for customer/address.
    Cheers,
    Custodio

  • Doubt about select in method.

    Hi Gurus.
    In Webdynpro can we use Select in method?
    If dont , how we can use the select comand in method? And why is not permited.?
    Thanks

    Hi Ronaldo,
    Though system does not throw any errors if we write select queries in WD component controller/view controller but we should never write a DB queries like select, insert, update, etc because it has an impact on performance of web dynpro application.
    Web dynpro applications are heavy and it runs in front end and hence only the ui logic to be placed in WD components and the business logic/db queries to be placed in a model viz, class / function module, etc.Hence WD implementation should strictly follow the MVC architecture
    For more details on MVC in WDA, please refer the below links
    Web Dynpro Architecture (SAP Library - Web Dynpro for ABAP)
    Architecture of Webdynpro for ABAP - Web Dynpro ABAP - SCN Wiki
    Hence, you should use either a class / function module to place your business logic and call the methods/ function modules inside the WD component.
    In general, for every WD component, a assistance class will be attached and it assists the component with business logic. So, we can call the method of an assistance class in WD component.
    Hope this helps you.
    Regards,
    Rama

  • Time issue of select statement

    Hi friends,
       I have a doubt about select single statement in this particular statement below.
    i have the code which goes this way.
    loop at itab.
    concatenate *year *materail no * item type into dummy variable.
    select single dmbtr from bsis into itab-dmbtr where xref3 = dummy variable and belnr = itab-migodoc and gjahr = itab-mjahr and hkont = '0000123'.
    clear dummy variable.
    modify itab.
    endloop.
    the bsis table has around 4,000,000 records.
    The report when executed goes smoothly till the point where the above select statement is encountered.
    my question is does it take time to execute because of so many records ?
    If not then why dies it take a lot of time to execute a single select statement ? 
    and how can i optimise the time consumed by this select query or report. ?
    Thank you.
    Moderator message: please understand the basic concept of using primary or secondary indexes in your queries, you will sure find the missing field in your where-clause, read the sticky threads of this forum.
    Edited by: Thomas Zloch on Nov 20, 2010 5:31 PM

    Hi Vivek,
    Data volume definitely gives impact on SQL.
    Don't use sql inside the loop, it will decrease the performance.
    Year material no. and item type may have duplicate entries. filter that. It may also gives impact on performance.
    Write a single Select query.
    Instead of fetching the data at once use packet size.
    http://wiki.sdn.sap.com/wiki/display/ABAP/ABAP4TuningChecklist
    Regards,
    Sudha
    Edited by: Sudha Rani Pathuri on Nov 20, 2010 6:42 PM
    Edited by: Sudha Rani Pathuri on Nov 20, 2010 6:48 PM
    Edited by: Sudha Rani Pathuri on Nov 20, 2010 6:51 PM

  • Select Statement Doubt

    Moderator message: Please use meaningful subject in future
    Hi,
    I've a requirement that I need to get a record from EREV table for a Purchase Requisition no. based on Latest Version No. (REVNO. ) at a single shot.
    I hav used the following code but i dint get desired values.
    Select EDOKN
              FGNAM
              FGDAT
              REVNO
           from EREV into ls_erev
           where edokn eq p_edokn and
                     revno eq (select Max(revno) from erev)).
    Any body pl help me.
    -Rajiv
    Edited by: Vaddepati on Dec 3, 2008 11:01 AM
    Edited by: Matt on Dec 3, 2008 10:03 AM

    Hi veddapati,
    Your sequence of using the fields in Select statement is wrong...thats why, you are not getting the required output..
    You should select revno in the select statement before FGNAM as it is present in the table..
    Please modify your select statement like this..... ::
    Select EDOKN
    REVNO
    FGNAM
    FGDAT
    from EREV into ls_erev
    where edokn eq p_edokn and
    revno eq (select Max(revno) from erev)).
    Hope it will solve your problem
    Regards,,
    Nikita
    Edited by: Nikita Jain on Dec 3, 2008 2:29 PM

  • Select statement operators in ecc 6.

    Hi Experts,
    I have a small doubt about the '>=' ( greater than or equal to ) operator usage in select statement. Is this operator by any chance perform not as desired in ECC 6.0. Is it a good option to use 'GE' instead of '>='. ?
    It may sound a bit awkward, but still I would like to know. I am facing a situation, which could be related to this. An early response would be highly appreciated.
    I would request,you NOT TO REPLY with links/explanations which says how to use select statement. Only answer if you have the  answers related to this query.
    Regards,
    Sandipan

    >
    Jaideep Sharma wrote:
    > Hi,
    > The only difference is GE will take a little more time than >= as system need to convert the keyword into actual operator when fetching data from Database.
    >
    > KR Jaideep,
    ????? Every Open SQL statements is translated to the SQL slang the underlying database is talking regardless if you type GE or >=
    If the result differs using >= or GE i would open a call at SAP instead of asking in SDN.

  • SELECT statement using XML data taking way too long.

    Hi all, I am using SQL Server 2005.
    I have an issue which I find hard to describe. The server that I am using contains two test databases which are (supposed to be) identical. They both have tables named EVENTS with identical fields. I am using XML data to query and update data to this table. 
    When I run the SELECT in one database, against the EVENTS table it takes a long time. The longest I've kept it running is 2:30 minutes. When I run it against the EVENTS table in the other database the results are almost instantaneous. I've created a test
    query to duplicate this behavior:
    declare @ValidXMLInput xmlset @ValidXMLInput = '<EVENTS>
    <EVENT EID="8077" EDATE="2014-07-20 10:15"
    USERID="GTJ789" LOCID="7016" STATE="0" />
    </EVENTS>'
    SELECT Col.value('@EID','VARCHAR(5)'),Col.value('@STATE','INT')
    FROM @ValidXMLInput.nodes('//EVENTS/EVENT') Tab(Col) 
    left join tblEvents on                   
     tblEvents.EvIdNum=Col.value('@EID','VARCHAR(5)') And
     tblEvents.EvDate=Col.value('@EDATE','DATETIME') And
      tblEvents.UserId=Col.value('@USERID','VARCHAR(8)') And
    tblEvents.EvLocId=Col.value('@LOCID','VARCHAR(8)') 
    where tblEvents.EvIdNum Is Null
    Basically, the above query returns all rows in the XML table that are not in the database table. The results are then passed on to other statements.The columns in the join are key fields for tblEvents and have a PK index for both tables (in each db).
    Now the issue that I am having. When I use an EID in the XML data of any other value (as presented in the example above), such as '3477' the query runs fast on both databases; however, when I specifically use an EID of '8077' then the query slows down to
    a point where it takes more than 2:30 minutes (after which I cancel the execution). This only happens with one of the databases.
    For testing purposes I've created an XML structure with only one item. Both tables have approximate 111 million records. One table contains about 900K records with an EID of 8077. The other table contains about 930K records with this EID. There aren't many
    differences in the data. The records with the EID of 8077 (the slow one) are for different dates, users and locations. I should also mention that although the data presented here for EID consists of number, provisions exist where the number may be prefixed
    by a letter; hence the varchar designation.
    My question to you all is: How can I start troubleshooting this issue? Should I be looking at indexes?
    I had some doubt about this because the query is fast for other EIDs. Why would it get "stuck" with this particular one?
    Any troubleshooting advice is welcomed. Thanks! Saga
    Insanity is the prelude to discovery

    Some thoughts:
    Is there a hardware difference between the two databases ? E.g. are they on the same disk (array) ?
    Is there anything else running on your server besides your SQL instance ?
    Do you see spikes in I/O, CPU or both ?
    Maybe there is locking on one DB that's not happening in the other.
    You should check indexes and statistics plus compare estimated execution plan between the two DBs.
    Also check this links:
    http://technet.microsoft.com/en-us/library/ms345118%28v=sql.90%29.aspx
    http://technet.microsoft.com/en-us/library/ms345115%28v=sql.90%29.aspx

  • Regarding select Statement in Partition

    Hi Friend,
    I have one doubt about Partition.
    CREATE TABLE list_part (
    deptno NUMBER(10),
    deptname VARCHAR2(20),
    quarterly_sales NUMBER(10,2),
    state VARCHAR2(2))
    PARTITION BY LIST (state) (
    PARTITION q1_northwest VALUES ('OR', 'WA') TABLESPACE part1,
    PARTITION q1_southwest VALUES ('AZ', 'CA', 'NM') TABLESPACE part2,
    PARTITION q1_northeast VALUES ('NY', 'VT', 'NJ') TABLESPACE part1,
    PARTITION q1_southeast VALUES ('FL', 'GA') TABLESPACE part2,
    PARTITION q1_northcent VALUES ('MN', 'WI') TABLESPACE part1,
    PARTITION q1_southcent VALUES ('OK', 'TX') TABLESPACE part2);
    I would create one table like in above example
    My doubt is how can i Select the data in particular tablespace For Example i'm selecting tablespace part1
    Give some example.
    Regards,
    Suresh Kumar

    You can only select from tables (or views).
    Tables are the logical representation of your data.
    Tablespaces are the physical storage of your data.
    When you select you don't care where the bits and bytes are coming from.
    You can of course match your select with a certain table partition.

  • Using if the else logic in regards to a select statement for a report

    Hi all,
    I've a question regarding if then else logic in Oracle.
    I'm developing a report application which contains 3 selectlists
    - ProductGroup - SubGroup - Manufacturer
    Each one containing several values. And are based on eachother, meaning if you select an item from the PG list, you only get the SG items regarding the PG item you've choosen before. The process logic should be as the following:
    When a user selects one item from for example the PG list, the query will be:
    select * from x where PG = :P_PG
    and the report displays all the items in the PG category selected
    The other two bindvariables would be null as the user didn't pick them
    If he then proceeds and selects one item from the SG list, the query would be:
    select * from x where PG = :P_PG and SG = :P_SG
    and the report displays all the items in the PG and SG category selected
    If he then proceeds and selects one item from the MA list, the query would be:
    select * from x where PG = :P_PG and SG = :P_SG and MA =:P_MA
    and the report displays all the items in the PG and SG and MA category selected
    Now, I've read some documentation about the decode function, but I can't figure it out, please help.
    Peter

    Okay, Chet, have set it up on htmldb, so you can see my problem, will go in high detail, it is not producing what I want. Example on htmldb:
    DEMO/test
    http://htmldb.oracle.com/pls/otn/f?p=33229:6
    Defenitions:
    3 LOV's, namely:
    - LOVPG - select distinct productgroep, productgroep pg from plijst
    - LOVSG - select distinct subgroep, subgroep sg from plijst where productgroep = :P6_LOVPG
    - LOVLE- select distinct leverancier, leverancier le from plijst where productgroep = :P6_LOVPG and subgroep = :P6_LOVSG
    3 Selectitems with submit, namely:
    - :P6_LOVPG
    - :P6_LOVSG
    - :P6_LOVLE
    Report region select statement:
    select * from plijst where (productgroep = :P6_LOVPG or :P6_LOVPG IS NULL) and (subgroep = :P6_LOVSG or :P6_LOVSG IS NULL) and (leverancier = :P6_LOVLE or :P6_LOVLE IS NULL)
    Branch to:
    Branche to page on submit after processing
    What it should do is:
    When you select an item from the first selectlist, productgroep, the report should show all rows containing the specified productgroep.
    When the user selects the next item in the subgroep selectlist, the report should show all rows containing the previously selected prodctgroup and the just selected subgroep.
    When the user selects the final item , the report should show all rows based on all three selected itemvalues, productgroep, subgroep, leverancier.
    The problem is that with this setup the report is only generated after the final selectlist choice of the user. But the user should see a report before that, going deeper into the structure. Hope, you see my problem?
    Sincerely,
    Pete

Maybe you are looking for