Diffrent options of select statement...

What are the different options for the select statement...If you could provide code samples that will be helpful...
Thanks
Jim

hi
<b>
SELECT statements
Reading Single Entries</b>
    e.g. Select single * from customers
<b>Getting statistical information using max, min, avg, sum</b>
<b>Reading each line using Select ….. EndSelect</b>
       e.g.      Select * from Customers.
              Write :/ Customers-name
            EndSelect
<b>Reading all the table entries using Select .</b>
        e.g. Select * from Customers into table all_Customers
<b>FROM variants</b>
FROM <dbtabname>                                          
... FROM <tabref1> [INNER] JOIN <tabref2> ON <cond>           
... FROM <tabref1> LEFT [OUTER] JOIN  <tabref2> ON <cond>           
<b>SELECT INTO variants</b>
INTO <wa>                                                    
... INTO CORRESPONDING FIELDS OF <wa>                            
... INTO (f1, ..., fn)                                         
... INTO TABLE <itab>                                            
... INTO CORRESPONDING FIELDS OF TABLE <itab>                    
... APPENDING TABLE <itab>                                       
... APPENDING CORRESPONDING FIELDS OF TABLE <itab>
<b>
SELECT – Loop function</b>
On change of
     SELECT * FROM T100
          WHERE SPRSL = SY-LANGU
          AND MSGNR < '010'
              ORDER BY PRIMARY KEY.                          
          ON CHANGE OF T100-ARBGB.                                        
                    ULINE.                                                        
                WRITE: / '**', T100-ARBGB, '**'.                            
          ENDON.                                                          
          WRITE: / T100-MSGNR, T100-TEXT.                                 
     ENDSELECT.
regards
ravish
<b>reward points if helpful</b>

Similar Messages

  • Issue with Select options in select statement - ABAP Question

    Hi
    I am facing an issue with select options. Select statement is returning sy-subrc as 4.
    I wrote the program as below:
    SELECT-OPTIONS:
    s_kunnr FOR bsad-kunnr,
    s_lifnr FOR bsak-lifnr,
    s_gjahr FOR bsad-gjahr,
    s_bukrs FOR bsad-bukrs,
    s_saknr FOR bsad-saknr,
    s_budat FOR bsak-budat.
    In start of selection I have written the select statement as
    SELECT * FROM bsak INTO TABLE lt_bsak
    WHERE bukrs IN s_bukrs AND lifnr = s_lifnr AND gjahr IN s_gjahr AND budat IN s_budat AND saknr IN s_saknr.
    In selection screen I have not entered any values and executed the program. I am not getting any result. When I debug that, sy-subrc is 4 at above select statement. But table has records.
    If am removing the "lifnr = s_lifnr " condition in select then select is returning values.
    I am not getting where I made the mistake. Please suggest.
    Thank you
    Hanu

    Hi,
    The problem here with where condition select option lifnr = s_lifnr.
    Use below select query.
    SELECT * FROM bsak INTO TABLE lt_bsak
    WHERE bukrs IN s_bukrs
        AND lifnr     IN s_lifnr
        AND gjahr   IN s_gjahr
        AND budat  IN s_budat
        AND saknr  IN s_saknr.
    s_lifnr is a select option and you are passing it as parameter lifnr = s_lifnr.
    if you want to pass this s_lifnr as single vale then pass in below mentioned way.
    lifnr = s_lifnr-low
    BR,
    Vijay

  • Intersection in Select statement

    Hi,
    Do any one know about some intersection option in select statement.
    My case is : I have 2 database tables say TAB1 and TAB2 . TAB1 has data (A, B, C, D) and TAB2 has data (B, D) now I want the output as (A and C) after joining these 2 tables and selecting.
    That is I want the values of Table1 which are not there in Table2.
    I have the option of selecting Table1 and then for all entries fetch Table2, then Loop at the Table & delete if record exists.
    But this is creating performance issue as the number of records in both tables are in Lakhs.
    So I wanted to know is there any option like Left Intersecion or some thing like left outer join and all, so that I can pick the dat in one select.
    Thanks,
    Sameer

    Issue solved :
    Sample Code
    TYPES : BEGIN OF X_VBAK,
            VBELN TYPE VBAK-VBELN,
            AUBEL TYPE VBRP-AUBEL.
    TYPES : END OF X_VBAK.
    DATA : I_VBAK TYPE STANDARD TABLE OF X_VBAK.
    DATA : I_VBAS TYPE STANDARD TABLE OF X_VBAK.
    SELECT  AVBELN BAUBEL INTO CORRESPONDING FIELDS OF TABLE I_VBAK FROM ( VBAK AS A
      LEFT OUTER JOIN VBRP AS B ON AVBELN EQ BAUBEL ).
    SORT I_VBAK BY VBELN.
    delete ADJACENT DUPLICATES FROM i_vbak COMPARING ALL FIELDS.
    DELETE I_VBAK WHERE AUBEL NE ''.
    SORT I_VBAK BY VBELN.
    SORT I_VBAS BY VBELN.

  • Query for select statement

    Dear all
    is there any option in select statement to automatically generate serial number respect of data.
    for eg.
    1 101100110  shetal trade
    2 1110001178 CHEMICAL SOAP WORKS
    3..
    4..
    i don't  want to use loop (sy-tabix) ..
    thanks,
    Abhi

    Hi ,
    i don't want to use loop (sy-tabix) ..
    any particular reason for this ?
    as u cannot automatically generate serial number, u have to go for loop....endloop.
    Thanks
    Karthik

  • SELECT OPTIONS use in select statement

    hi,
    I have defined my selection screen in the main program.
    selection-screen begin of screen 0101 as subscreen.
    selection-screen begin of block b1.
    select-options:  S_KUNNR for  KNA1-KUNNR,
    selection-screen end of block b1.
    selection-screen end of screen 0101.
    then in an include in the same module pool, i try to use this in select statement
    SELECT * INTO CORRESPONDING FIELDS OF XXX FROM ZPPP WHERE KUNNR IN S_KUNNR.
    I get  an error saying " the IN operator with S_KUNNR is neither followed by an internal table nor by a valuelist "..what does this mean ?
    thks

    Check the sample code...
    REPORT  ztest_mod.
    DATA: kunnr TYPE kunnr.
    * Custom Selection Screen 0200
    SELECTION-SCREEN BEGIN OF SCREEN 0200 AS SUBSCREEN.
    SELECT-OPTIONS: s_kunnr FOR  kunnr.
    SELECTION-SCREEN END OF SCREEN 0200.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_kunnr-low.
      BREAK-POINT.
    START-OF-SELECTION.
      "in this screen i have a button with function code 'SEARCH'
    " and a subscreen area with name sub
      CALL SCREEN 100.
    *&      Module  STATUS_0100  OUTPUT
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS'.
    ENDMODULE.                    "status_0100 OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    MODULE user_command_0100 INPUT.
      DATA: it_kunnr TYPE TABLE OF kna1.
      CASE sy-ucomm.
        WHEN 'SEARCH'.
          SELECT * FROM kna1
          INTO TABLE it_kunnr
          WHERE kunnr IN s_kunnr.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                    "user_command_0100 INPUT
    in the flow logic..
    PROCESS BEFORE OUTPUT.
      MODULE status_0100.
      CALL SUBSCREEN sub INCLUDING sy-repid '0200'.
    PROCESS AFTER INPUT.
      MODULE user_command_0100.
    Regards
    Vijay Babu Dudla

  • Select statement for generic select options

    Hello,
    I have a problem implementing a SELECT-Statement. I have a generic number of select options on my selection screen and I have a range table for each select option. How can a generate a database select for these generic number of range tables?
    Thank you very much in advance & regards,
    Alexander

    the answer I gave you will work if you have a ranges table for every possible select-options and refer to every ranges table in your where clause.... that way, you don't have to know which are populated and which are not at the time of SELECT.
    You could also choose to create a dynamic where clause, based upon what you had select-options for and use with
    WHERE ( whereclause ).
    Edited by: BreakPoint on Mar 2, 2011 4:31 PM

  • Where condition with optional fields in select statement

    Hi,
    In a function module I have to fetch data based on 7 fields out of which 6 are optional.
    If we won't enter values for optional fields it will take default values as zeroes .
    So this is not fetching data. But for some fields some values has zero values.
    How to solve this condition?
    Regards,
    maha.

    Hi,
    For those import parameters for which its mentioned as optional, use like condition in the where clause of select statement in the function module.
    try like this,
    concatenate pfield2 '%' into pfield2.
    concatenate pfield3 '%' into pfield3.
    concatenate pfield4 '%' into pfield4.
    concatenate pfield5 '%' into pfield5.
    concatenate pfield6 '%' into pfield6.
    concatenate pfield7 '%' into pfield7.
    select *
    from db table
    into itab
    where field1 = pfield1 and
               field2  like pfield2 and
               field3  like pfield3 and
               field7 like pfield7.
    Now even if the optional fields are blank, data will be selected
    Regards,
    Vik

  • HT2534 While creating an account from my iPad there is no option for selecting none in the payment options. It states I have to give my credit card details. What's the procedure to open a free account?

    While creating an account from my iPad there is no option for selecting none in the payment options. It states I have to give my credit card details. What's the procedure to open a free account?

    It's in the article.  You must first sign-out your current account, then go to App store to purchase a Free App.  It will ask you to either Sign in or create a new AppleID.  That's when you start creating a new AppleaID and NONE will be available as a payment option.

  • 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.

  • Secondary Index Select Statement Problem

    Hi friends.
    I have a issue with a select statement using secondary index,
    SELECT SINGLE * FROM VEKP WHERE VEGR4 EQ STAGE_DOCK
                                      AND VEGR5 NE SPACE
                                      AND WERKS EQ PLANT
            %_HINTS ORACLE
            'INDEX("&TABLE&" "VEKP~Z3" "VEKP^Z3" "VEKP_____Z3")'.
    given above statement is taking long time for processing.
    when i check for the same secondary index in vekp table i couldn't see any DB index name with vekp~z3 or vekp^z3 or vekp____z3.
    And the sy-subrc value after select statement is 4. (even though values avaliable in VEKP with given where condition values)
    My question is why my select statement is taking long time and sy-subrc is 4?
    what happens if a secnodary index given in select statement, which is not avaliable in that DB Table?

    Hi,
    > ONe more question: is it possible to give more than one index name in select statement.
    yes you can:
    read the documentation:
    http://download.oracle.com/docs/cd/A97630_01/server.920/a96533/hintsref.htm#5156
    index_hint:
    This hint can optionally specify one or more indexes:
    - If this hint specifies a single available index, then the optimizer performs
    a scan on this index.  The optimizer does not consider a full table scan or
    a scan on another index on the table.
    - If this hint specifies a list of available indexes, then the optimizer
    considers the cost of a scan on each index in the list and then performs
    the index scan with the lowest cost. The optimizer can also choose to
    scan multiple indexes from this list and merge the results, if such an
    access path has the lowest cost. The optimizer does not consider a full
    table scan or a scan on an index not listed in the hint.
    - If this hint specifies no indexes, then the optimizer considers the
    cost of a scan on each available index on the table and then performs
    the index scan with the lowest cost. The optimizer can also choose to
    scan multiple indexes and merge the results, if such an access path
    has the lowest cost. The optimizer does not consider a full table scan.
    Kind regards,
    Hermann

  • BI Publisher : SELECT statement in RTF template

    Hi Guys
    I have written a BI Publisher Report using XML file created from Oracle Reports(in Oracle Apps).
    Repors runs from Oracle Apps perfectly ok. Now I need to fetch some data from couple of tables and display on the Report.
    I am wondering whether I can directly code SELECT statement in RTF file rather than messing with Oracle Report(.rdf) file.
    Please advise.
    Thanks and Regards
    Vijay

    Hey Vijay,
    You cannot query in RTF using select :)..
    You have to mess/play with RDF to do it ;)
    Oh wait, did i say , we cannot in RTF, we can , but that is difficult approach to go with., keep this as an end of the world option.

  • Is there any  way to Mask the Name when  a select statement is issued?

    Dear all,
    Is there any way to mask the name .. i mean if User issue a select statement in a customer table the real name should come like ' ABCXXXDEFXXCFXX'... Which is not the actual name?
    e.g if Name: CHIEV SONG MEE
    If user issue a statment select * from customers;
    The Result Should come something Like this:
    Name
    CHXXV SXNG MXX
    Thank You

    user3029023 wrote:
    but it seems there is no option in oracle it self which can be used as there they are saying to get a data masking software which we can't due to some internal issues....I would not say that. How one implements masking depends entirely on the requirements that need to be met.
    For example, schema A owns all the tables. Schema B can be created as a "trusted" schema - in other words, schema A trusts schema B and allows it full access (with grants) to its tables. Schema B implements data masking as views. For each table in A, a view exists in B that implements the required masking. B can now grant select access on these views to user C. User C will see the same data object names in B as it would have if it used A - only, by using the B data objects it uses masked data objects and not the original source data objects.
    Another example - schema Dev is to have all the data objects of schema Prod, but masked where needed. One can use CTAS (Create Table As Select) to create the required tables in Dev with masked values where relevant. This Dev schema can be "refreshed" on weekends by dropping all tables and getting a new fresh copy of production data and masking it - ready for the next week's development cycle.
    If the application use is for example APEX, then instead of coding SQL directly as reporting regions to display, a function is used instead. APEX supports reporting regions where it calls a function and this function provides the APEX run-time with the SQL to execute and contents to render. It is easy to use this approach to implement logic in functions that masked column data depending on who the APEX user is, the security/role attributes of the user, and so on.
    No there is not a single "+mask this column!+" feature in Oracle.. but that does not mean that such a feature is not supported and cannot be implemented. Oracle has a very comprehensive and rich set of tools - more so than most (if not all) other RDBMS products.
    It is up to the architect/designer/developer to use this toolkit in creating a system that meets the specific requirements at hand.

  • SELECT statement with 'IN'

    Hi,
    If SELECT statement has IN in the where clause, does that use the index?
    For example,
    SELECT t1 f2 f4 from ztest
    WHERE
                  fid IN     s_id    AND
                  doctype     IN s_doctype AND
                  year     IN s_year    .
    What is the other option to optimize the SELECT with IN?
    Thanks & regards,
    Yogita

    Moderator message - Please search before asking - post locked
    Rob

  • How to model in OWB if you have a subquery in your select statement? (11.2)

    Which operator (is it the Table operator) to use if I have a subquery as part of my select statement? (The way I do it works, but is not elegant. What I do is create a table for the subquery and than join that with the other sources to point to my target.) But, would appreciate the best way with OWB's features.
    Here is the entire SQL (including the subquery):
    SELECT to_numbe (null), course_id
    at.book, lp.NAME,
    (select b.pricing from qp_pricing_attributes b
    where b.list_id = ll.list_id and b.product = at.product) sign,
    ll.operand AS price, lhb.comments
    FROM
    pricing_attribs at,
    list_lines ll,
    list_h lp,
    list_b lhb
    WHERE 1 = 1
    and ll.list_line_id = atrib.list_line_id
    AND ll.list_header_id = lp.list_header_id
    AND lp.list_header_id = lhb.list_header_id
    Thanks you.

    Hi
    Doesn't need to be a table in the target. Let's take a very simple example, let's say you wanted to do the following;
    select ename,(select dname from dept d where d.deptno=e.deptno) from emp e
    Then DEPT is your lookup table and EMP is your driving table.
    1. Add EMP on to the canvas.
    2. Add in lookup operator
    3. Bind lookup to DEPT
    4. Hit finish
    5. Map EMP.DEPT to DEPT.INGRP1 (the lookup operator)
    6. Edit lookup operator, on Lookup Conditions tab set DEPTNO for lookup column, and DEPTNO for input attribute
    7. Lookup complete now
    You can add in a target table operator and map from the source EMP table and the output attributes of the lookup operator. you can change step 4 to carry on through wizard and define lookup, but I have chosen to do 5, to automatically get the names and datatypes of the inputs. There are lot of other options now in 11gR2 in the lookup.
    Hope this makes sense.
    Cheers
    David

  • Limitation on SQL executing select statement from ADO and Oracle 8.1.7.1 OleDB Driver

    Hi,
    we are running a query with a big dunamic select statement from VB code using ADO command object. When Execute method is called system hangs and control won't return back to the application. it seems to be that there is some type limitation on Query string length. Please tell us if there is any?
    we are running Oracle 8.1.7 Server on Windows 200 Server and connecting from a W2K professional, ADO 2.6 and Oracle OLEDB 8.1.7.1 OLEDB Driver.
    Sample code:
    Dim rs As ADODB.Recordset
    Dim cmd As ADODB.Command
    Set cmd = New Command
    With cmd
    .CommandText = ' some text with more than 2500 characters
    .CommandType = adCmdText
    Set rs = .Execute
    End With
    when i debug using VB6 and when .Execute line is called system hangs or return a message method <<somemethod> of <<some class name>> failed error.
    Any help is appreciated.
    Thanks,
    Anil

    A stored procedure would only slow you down here if it was poorly written. I suspect you want to use the translate function. I'm cutting & pasting examples from the documentation-- a search at tahiti.oracle.com will give you all the info you'll need.
    Examples
    The following statement translates a license number. All letters 'ABC...Z' are translated to 'X' and all digits '012 . . . 9' are translated to '9':
    SELECT TRANSLATE('2KRW229',
    '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
    '9999999999XXXXXXXXXXXXXXXXXXXXXXXXXX') "License"
    FROM DUAL;
    License
    9XXX999
    The following statement returns a license number with the characters removed and the digits remaining:
    SELECT TRANSLATE('2KRW229',
    '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', '0123456789')
    "Translate example"
    FROM DUAL;
    Translate example
    2229
    Also, LIKE '%<string>%' is going to be rather expensive simply because it has to compare the entire string and because it forces full table scans, rather than using indexes. You could speed this sort of query up by using interMedia Text (Oracle Text now in 9i). If you can eliminate one of the '%' options, you could also improve things.
    My guess is that your stored procedure is inefficient and that's causing the problem-- 5k rows per table should be pretty trivial.
    If you post your query over on the PL/SQL forum, there are better performance tuners than I that might have more hints for you. To get really good advice, though, you'lllikely have to get at least the execution plan for this statement and may need to do some profiling to identify the problem areas.
    Justin

Maybe you are looking for