How to re-arrange columns when outputting a SELECT statement?

Assume a table holds a lot of columns: A, B, C, D, E,......., Z
When outputting the result auf a SELECT statement the columns should be re-arranged as follows:
The first column should be E, then the second column should be C and then all remaining columns should
follows in a order as if there would be no re-ordering. How can I do this in SQL WITHOUT having to list all
columns individually like in:
SELECT E,C, A, B,D,F,.....,Z FROM .....
Furthermore the first and second column should not re-appear again (twice) as in a statement like
SELECT E, C, * FROM .....;
How can I achieve this?
Peter

Hi,
Welcom to the forum!
Posting your own question in someone else's thread is called "hijacking".
More people will read (and answer) your question if you start your own thread.
You can include a link to this thread, if you think that will help people. See the "Plain Text Help" on the right side of the "Edit Message" screen to learn how.
If you have more output than will fit on one line, then you can
(1) Increase the size of the line, or
(2) Decrease the size of the output
or both.
Display issues like this always depend on your front-end.
For example, in SQL*Plus you can use SET LINESIZE to make lines bigger, and COLUMN to reduce wasted space within the lines.
When you start your own thread, be sure to mention your front-end tool and version.

Similar Messages

  • How to pull only column names from a SELECT query without running it

    How to pull only column names from a SELECT statement without executing it? It seems there is getMetaData() in Java to pull the column names while sql is being prepared and before it gets executed. I need to get the columns whether we run the sql or not.

    Maybe something like this is what you are looking for or at least will give you some ideas.
            public static DataSet MaterializeDataSet(string _connectionString, string _sqlSelect, bool _returnProviderSpecificTypes, bool _includeSchema, bool _fillTable)
                DataSet ds = null;
                using (OracleConnection _oraconn = new OracleConnection(_connectionString))
                    try
                        _oraconn.Open();
                        using (OracleCommand cmd = new OracleCommand(_sqlSelect, _oraconn))
                            cmd.CommandType = CommandType.Text;
                            using (OracleDataAdapter da = new OracleDataAdapter(cmd))
                                da.ReturnProviderSpecificTypes = _returnProviderSpecificTypes;
                                //da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
                                if (_includeSchema == true)
                                    ds = new DataSet("SCHEMASUPPLIED");
                                    da.FillSchema(ds, SchemaType.Source);
                                    if (_fillTable == true)
                                        da.Fill(ds.Tables[0]);
                                else
                                    ds = new DataSet("SCHEMANOTSUPPLIED");
                                    if (_fillTable == true)
                                        da.Fill(ds);
                                ds.Tables[0].TableName = "Table";
                            }//using da
                        } //using cmd
                    catch (OracleException _oraEx)
                        throw (_oraEx); // Actually rethrow
                    catch (System.Exception _sysEx)
                        throw (_sysEx); // Actually rethrow
                    finally
                        if (_oraconn.State == ConnectionState.Broken || _oraconn.State == ConnectionState.Open)
                            _oraconn.Close();
                }//using oraconn
                if (ds != null)
                    if (ds.Tables != null && ds.Tables[0] != null)
                        return ds;
                    else
                        return null;
                else
                    return null;
            }r,
    dennis

  • Database adapter and column aliases in the select statement (10.1.3.1)

    Hi,
    Is it possible to use column aliases in the select statement for a database adapter to return an xml element name which is different to the column in the queried table?
    I have tried using
    SELECT EMPLOYEE_ID, FIRST_NAME AS MYNAME, LAST_NAME, SALARY, DEPARTMENT_ID, PHONE_NUMBER, EMAIL, HIRE_DATE FROM HR.EMPLOYEES WHERE (DEPARTMENT_ID = #DEPT_ID)
    but I get the following XML fragment returned
    <Employees>
    <employeeId>100</employeeId>
    <firstName xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
    <lastName>King</lastName>
    <salary>24000</salary>
    Any pointers appreciated.
    Joel.

    That is really interesting.
    When I use the "custom sql" option in the DB adapter wizard, it used the aliases just fine in the return schema.
    Marc

  • How to edit the records value fetched by select statement query in sqldever

    How to edit the records value fetched by select statement query in sqldever 2.1.1.
    EX-
    SELECT * FROM emp WHERE ename like 'Jaga%'
    Edited by: user9372056 on Aug 31, 2010 2:16 AM

    Hi,
    Although some forum members may be using that tool, there is still a dedicated forum for SQL Developer.
    SQL Developer
    Maybe your chances are better there.
    Regards
    Peter

  • How to call an action when the user selects a radiobutton

    Hai
    PLease help me in providing the information.
    In my Project i have two radio buttons as
    New
    Asssessment
    when the user selects new button, i want to automatically call an action in the controller(.jpf file)
    Simalarly when he selects the other radio button i need to call a separate action in the controller.
    Remember i dont have the submit button.
    I want to dynamically call an action when the user selects the radio button.
    i dont have any field inthe radio button which actually takes action as an attribute .
    please provide me the necessary

    Hi,
    You can use JavaScript to call the action in interest upon the Radio Button Element Being Selected.Should be simple, and if your controller is part of the portlet dont forget to use the jpfScopeId to asscoiate the controller instance with the one in the portlet.
    Let me know if you have any further questions.

  • Using column number inplace of column name in SQL Select statement

    Is there a way to run sql select statements with column numbers in
    place of column names?
    Current SQL
    select AddressId,Name,City from AddressIs this possible
    select 1,2,5 from AddressThanks in Advance

    user10962462 wrote:
    well, ok, it's not possible with SQL, but how about PL/SQL?As mentioned, using DBMS_SQL you can only really use positional notation... and you can also use those positions to get the other information such as what the column is called, what it's datatype is etc.
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2) IS
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_rowcount  NUMBER := 0;
    BEGIN
      -- create a cursor
      c := DBMS_SQL.OPEN_CURSOR;
      -- parse the SQL statement into the cursor
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      -- execute the cursor
      d := DBMS_SQL.EXECUTE(c);
      -- Describe the columns returned by the SQL statement
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      -- Bind local return variables to the various columns based on their types
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); -- Varchar2
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);      -- Number
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);     -- Date
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);  -- Any other type return as varchar2
        END CASE;
      END LOOP;
      -- Display what columns are being returned...
      DBMS_OUTPUT.PUT_LINE('-- Columns --');
      FOR j in 1..col_cnt
      LOOP
        DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' - '||case rec_tab(j).col_type when 1 then 'VARCHAR2'
                                                                                  when 2 then 'NUMBER'
                                                                                  when 12 then 'DATE'
                                                         else 'Other' end);
      END LOOP;
      DBMS_OUTPUT.PUT_LINE('-------------');
      -- This part outputs the DATA
      LOOP
        -- Fetch a row of data through the cursor
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        -- Exit when no more rows
        EXIT WHEN v_ret = 0;
        v_rowcount := v_rowcount + 1;
        DBMS_OUTPUT.PUT_LINE('Row: '||v_rowcount);
        DBMS_OUTPUT.PUT_LINE('--------------');
        -- Fetch the value of each column from the row
        FOR j in 1..col_cnt
        LOOP
          -- Fetch each column into the correct data type based on the description of the column
          CASE rec_tab(j).col_type
            WHEN 1  THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
            WHEN 2  THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_n_val);
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'));
          ELSE
            DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
            DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
          END CASE;
        END LOOP;
        DBMS_OUTPUT.PUT_LINE('--------------');
      END LOOP;
      -- Close the cursor now we have finished with it
      DBMS_SQL.CLOSE_CURSOR(c);
    END;
    SQL> exec run_query('select empno, ename, deptno, sal from emp where deptno = 10');
    -- Columns --
    EMPNO - NUMBER
    ENAME - VARCHAR2
    DEPTNO - NUMBER
    SAL - NUMBER
    Row: 1
    EMPNO : 7782
    ENAME : CLARK
    DEPTNO : 10
    SAL : 2450
    Row: 2
    EMPNO : 7839
    ENAME : KING
    DEPTNO : 10
    SAL : 5000
    Row: 3
    EMPNO : 7934
    ENAME : MILLER
    DEPTNO : 10
    SAL : 1300
    PL/SQL procedure successfully completed.
    SQL> exec run_query('select * from emp where deptno = 10');
    -- Columns --
    EMPNO - NUMBER
    ENAME - VARCHAR2
    JOB - VARCHAR2
    MGR - NUMBER
    HIREDATE - DATE
    SAL - NUMBER
    COMM - NUMBER
    DEPTNO - NUMBER
    Row: 1
    EMPNO : 7782
    ENAME : CLARK
    JOB : MANAGER
    MGR : 7839
    HIREDATE : 09/06/1981 00:00:00
    SAL : 2450
    COMM :
    DEPTNO : 10
    Row: 2
    EMPNO : 7839
    ENAME : KING
    JOB : PRESIDENT
    MGR :
    HIREDATE : 17/11/1981 00:00:00
    SAL : 5000
    COMM :
    DEPTNO : 10
    Row: 3
    EMPNO : 7934
    ENAME : MILLER
    JOB : CLERK
    MGR : 7782
    HIREDATE : 23/01/1982 00:00:00
    SAL : 1300
    COMM :
    DEPTNO : 10
    PL/SQL procedure successfully completed.
    SQL> exec run_query('select * from dept where deptno = 10');
    -- Columns --
    DEPTNO - NUMBER
    DNAME - VARCHAR2
    LOC - VARCHAR2
    Row: 1
    DEPTNO : 10
    DNAME : ACCOUNTING
    LOC : NEW YORK
    PL/SQL procedure successfully completed.
    SQL>

  • Select a column from an inner select statement

    On my oracle 10g running on solaris, I am running this little query that gives me
    the right results (I needed one more column and not able to get to it, hence looking for some ideas here)
    Select a.othtype, a.date_from, a.date_to,b.process
    from bio_plan_other a,
    bio b,
    Where a.bkey = b.bkey
    and a.date_from <
    (Select min(f.edate)
    from bio_service f
    where f.bkey = a.bkey) ;
    In the inner select table bio_service, I have an additional column called service_name. Hence for the min(f.edate), there is a corresponding service_name.
    How do I get that service_name in my topmost SELECT statement ?
    In other words, I wanted to do something like...
    Select a.othtype, a.date_from, a.date_to,b.process,f.service_name
    from bio_plan_other a,
    bio b,
    Where a.bkey = b.bkey
    and a.date_from <
    (Select min(f.edate)
    from bio_service f
    where f.bkey = a.bkey) ;
    But this gives me,
    ORA-00904 : f.service_name : invalid identifier
    Thanks

    Hi
    Not knowing your datamodel, but you probably have more service names per date, so did you try this?
    WITH t_bio_service AS (SELECT b2.bkey, b2.min_edate, b.service_name
                             FROM bio_service b
                                , (SELECT MIN(edate) min_edate, bkey
                                     FROM bio_service
                                    GROUP BY bkey) b2
                            WHERE b2.bkey = b.bkey
                              AND b2.min_edate = b.edate)
    SELECT a.othtype, a.date_from, a.date_to,b.process, t.service_name
      FROM bio_plan_other a,
           bio b,
           t_bio_service t
    WHERE a.bkey = b.bkey
       AND t.BKEY = b.bkey
       AND a.date_from < t.min_edateHope this helps.
    Regards Auke

  • How to return the result set of multiple select statements as one result set?

    Hi All,
    I have multiple select statements in my stored procedure that I want to return as one result set 
    for instance 
    select id from tableA
    union 
    select name from table b 
    but union will not work because the result sets datatypes are not identical so how to go about this ?
    Thanks

    You have to CAST or CONVERT (or implicitly convert) the columns to the same datatype.  You must find a datatype that both columns can be converted to without error.  In your example I'm guessing id is an int and name is a varchar or nvarchar. 
    Since you didn't convert the datatypes, SQL will use its data precedence rules and attempt to convert name to an int.  If any row contains a row that has a value in name that cannot be converted to an int, you will get an error.  The solution is
    to force SQL to convert the int to varchar.  So you want something like
    select cast(id as varchar(12)) from tableA
    union
    select name from tableb
    If the datatypes are something other that int or varchar, you must find a compatable datatype and then convert one (or both) of the columns to that datatype.
    Tom

  • How to create a cursor on a union select statement?

    Hi,
    Using Oracle 10g RAC +ASM ( RELEASE 1002000300)
    What are is the proper way to create a cursor on a union select statement?
    Is it possible?
    code lines, Results in PLS-00201 error: sT := crsR.STATUS; sS := crsR.TIME;
    Procedure listed below:
    CREATE OR REPLACE PROCEDURE BUILD_SUMMARY IS
    CURSOR csrO IS
    SELECT
    STATUS,
    TIME
    FROM (
    SELECT
    SUBSTR(DESCRIPTION,1,50) STATUS,
    TO_CHAR(TIMESTAMP,'MM/DD/YY hh12:mi:ss') TIME
    FROM GLOBALSALES.CUBE_STATUS
    UNION ALL
    SELECT
    ' TOTAL BUILD TIME',
    TO_CHAR(TO_DATE('00:00:00','HH24:MI:SS') +(MAX(TIMESTAMP) - MIN(TIMESTAMP)), 'HH24:MI:SS')
    FROM GLOBALSALES.CUBE_STATUS);
    csrR csrO%ROWTYPE;
    sT LONG :='';
    sS LONG :='';
    BEGIN
    FOR csrR IN csrO
    LOOP
    sT := crsR.STATUS;
    sS := crsR.TIME;
    DBMS_OUTPUT.PUT_LINE(sT || ' ' || sS);
    END LOOP;
    END;
    /

    csrR csrO%ROWTYPE;
    Declares the csrR correct? Cursor Record of Cursor Object Type?That line declares one variable CSRR with your column structure described by the cursor (CSRO) type you declared above it. It means the CSRR variable has the columns you had in the SELECT statement in that cursor.
    When you run a cursor as you did you don't need to declare the record variable. Try this:
    CREATE OR REPLACE PROCEDURE build_summary IS
      CURSOR csro IS
        SELECT status, TIME
          FROM (SELECT substr(description, 1, 50) status, to_char(TIMESTAMP, 'MM/DD/YY hh12:mi:ss') TIME
                  FROM globalsales.cube_status
                UNION ALL
                SELECT ' TOTAL BUILD TIME',
                       to_char(to_date('00:00:00', 'HH24:MI:SS') + (MAX(TIMESTAMP) - MIN(TIMESTAMP)),
                               'HH24:MI:SS')
                  FROM globalsales.cube_status);
      --csrr csro%ROWTYPE;
      st   LONG := '';
      ss   LONG := '';
    BEGIN
      FOR csrr IN csro
      LOOP
        st := csrr.status;
        ss := csrr.time;
        dbms_output.put_line(st || ' ' || ss);
      END LOOP;
    END;Also why are you using LONG? It's a deprecated data type and Oracle recommends against using it. Either pick varchar2(4000) or CLOB.
    DBMS_OUTPUT.PUT_LINE will implicitly convert that LONG data type anyway.

  • How to generate mutiple Results for multiple SQL SELECT statements

    I just downloaded SQL Developer 1.5 and play around with it.
    On a daily basis, I need run 4 different SELECT statements and dump the output of each SELECT into an CSV file and send to some users. In SQL Navigator, I can select all 4 SELECT statements and execute them at same time. Once all complete, I will see 4 tabs, each represent the output for each SELECT statement. Then I can export output from each tab into a CSV file.
    It seems that SQL Developer 1.5 still can't run mutiple SELECT statements and display the output of each statement into a separate "Results" tab so that I can export the data into multiple CSV files easily.
    Right now, I have to hightlight each SELECT statement and press F9, then export the output data into CSV.
    I wish I can execute 4 SELECT statements all in once on SQL Developer and get all the output data and export 4 times into 4 CSV files.
    Thanks!
    Kevin

    How about doing it as a set of tabs within the Resuls Tab?
    So you would have your Top row of tabs:
    Results, Script Output, Explain, AutoTrace, DBMS Output and OWA Output
    Then When you have the Results tab selected you could have a row of tabs beneath the Top row with one tab for each result set. Switching between result sets should switch which section of SQL is highlighted as the "Current SQL".
    A similar mechinism could be employed for each of the top level tabs where it makes sense to have multiple output tabs.
    A further refinement of this feature might be to allow the result tabs to be dockable within the parent tab so that multiple result tabs can be viewed simultaneously. This way 2 or more explain plans (for example) could be visually compared without requiring the code to exist in two separate code panes.

  • How do I return the results of two SELECT statements in to one result?

    I want to do this without using UNION.
    Here's an example of what I'm trying to do:
    I have a table called COUNTRY with the following columns:
    COUNTRY
    COUNTRY_CODE
    DATE_VISITED_LAST
    POPULATIONI have another table called STATE_COUNTY with the following columns:
    STATE_COUNTY
    COUNTRY_CODE
    STATE_COUNTY_CODE
    DATE_LAST_VISITED
    POPULATIONI have a third table called TOWN with the following columns:
    TOWN
    COUNTRY_CODE
    STATE_COUNTY_CODE
    TOWN_CODE
    DATE_LAST_VISITED
    POPULATIONNow through the interface I have, a user will supply a country code. I need a SELECT statement that will return a table with the following result set:
    The COUNTRY_CODE entered including the DATE_LAST_VISITED and POPULATION for this country
    ------> All the associated STATE_COUNTY's belonging to this country along with the DATE_LAST_VISITED and POPULATION for each STATE_COUNTY_CODE.
    -------------> All the associated TOWN_CODE's belonging to this state_county and country along with the DATE_LAST_VISITED and population for each TOWN.
    So the table will have 9 columns:
    COUNTRY
    DATE_LAST_VISITED_COUNTRY
    POPULATION_COUNTRY
    STATE_COUNTY
    DATE_LAST_VISITED_STATE_COUNTY
    POPULATION_COUNTY
    TOWN
    DATE_LAST_VISITED_TOWN
    POPULATION_TOWNAny ideas how this can be done?
    Thanks.

    Hi guys,
    Would it be ok to do it like this (with a join):
    SELECT      
         c.country_code,
         c.date_last_visited AS DATE_LAST_VISITED_COUNTRY,
         c.population AS POPULATION_COUNTRY,
         s.state_county_code,
         s.date_last_visited AS DATE_LAST_VISITED_STATE_COUNTY,
         s.population AS POPULATION_COUNTY,
         t.town_code,
         t.date_last_visited AS DATE_LAST_VISITED_TOWN,
         t.population POPULATION_TOWN,
    FROM
         country c
         LEFT OUTER JOIN state_county s ON s.country_code = c.country_code
         LEFT OUTER JOIN town       t ON t.country_code = s.country_code
    AND                                       t.state_county_code = s.state_county_codeThe results required would be something like:
    Country_Code     DATE_LAST_VISITED_COUNTRY     POPULATION_COUNTRY     STATE_COUNTY_CODE         DATE_LAST_VISITED_STATE_COUNTY         POPULATION_COUNTY     TOWN_CODE     DATE_LAST_VISITED_TOWN     POPULATION_TOWN
    UK               14-JAN-09                     56,00000               London                    18-JUL-99                              23,0000               Ascot         30-JUN-89                  12,000
                                                                                                                                                                 Brixton       28-JAN-92                  4,684
                                                                          Birmingham                12-SEP-09                              55,678                Solihull      12-OCT-81                  6.768 Does this make sense?
    Thanks!
    Edited by: Sastry on Nov 2, 2009 2:04 AM

  • How to use Oracle Table Type values in Select Statement.

    Hi,
    I am fetching initial set of values into Oracle Table of Records Type and want to use list of values in the Select statement.
    For example, try something like the following:
    TYPE t_record IS RECORD (
    ID TABLEA.ID%type,
    NO TABLEA.NO%type,
    v_record t_record;
    TYPE t_table IS TABLE OF v_record%TYPE;
    v_table t_table;
    -- Code to populate the values in v_table here.
    SELEC ID,NO, BULK COLLECT INTO <some other table variabes here> FROM TABLEA
    WHERE ID IN v_table(i).ID;
    I want to know how to use the values from Oracle Table Type in the Select Statement.

    Something like this:
    create or replace type t_record as  object (
    id number,
    no number
    CREATE or replace type t_table AS TABLE OF t_record;
    set serveroutput on
    declare
      v_table t_table := t_table();
      v_t1 t_table := t_table();
    begin
      v_table.extend(1);
      v_table(1).ID := 1;
      v_table(1).No := 10;
      v_table.extend(1);
      v_table(2).ID := 2;
      v_table(2).ID := 20;
      SELEC t_record (ID,NO) BULK COLLECT INTO v_t1
      from TableA
      FROM TABLEA
      WHERE ID IN (select t.ID from table(v_Table) t);
      for i in 1..v_t1.count loop
        dbms_output.put_line(v_t1(i).ID);
        dbms_output.put_line(v_t1(i).No);
      end loop;
    end;
    /Untested!
    P;
    Edited by: bluefrog on Mar 5, 2010 5:08 PM

  • How to use a table name in the select statement using a variable?

    Hi Everybody,
                       I got a internal table which has a field or a variable that gets me some tables names. Now I need to retrieve the data from all these tables in that field dynamically at runtime. So could you suggest me a way out to use the select query which uses this variable as a table ?
    Regards,
    Mallik.

    Hi all,
    Actually i need some more clarification. How to use the same select statement, if i've to use the tabname in the where clause too?
    for ex : select * from (tab_name) where....?
    Can we do inner join on such select statements? If so how?
    Thanks & Regards,
    Mallik.

  • How to pass parameter in Function by using select statement?

    Hi,
    I got a problem. I cant pass in parameter to function by using select statement. But it can pass in parameter by using 'hardcode' method. How can I solve this problem?
    Eg,
    select * from table (SplitFunction('HS750020,HS750021')) <<< this work.
    but
    select * from table (SplitFunction(select LOT_NO from TRACER_SEARCH_SCHEDULE where JOB_ID = '36')) <<< do not work.
    Thanks for who try to help. Thanks.

    skymonster84 wrote:
    I have try this before. But it not work.here is an example
    create or replace type stringlist as table of varchar2(100)
    create or replace function splitstring(pstring in varchar2) return stringlist
    as
      lstringlist stringlist;
    begin
      select regexp_substr(pstring,'[^,]+',1, level) bulk collect into lstringlist
        from dual
      connect by level <= length(pstring)-length(replace(pstring,','))+1;
      return lstringlist;
    end;
    select * from table(select splitstring('xx,yy,zz') from dual)
    create table t(str varchar2(100))
    insert into t values('x,y,z')
    insert into t values('a,b,c')
    select * from table(select splitstring(str) from t where rownum<2)
    /If you supply multiple values then it will fail.
    select * from table(select splitstring(str) from t)
    /

  • How imrove the peformance of VBFA table in select statements.

    Hi,
    whenever execute program in production, program execution will taking long time due to below select statement.
    Please help me how we imrove performance?
    SELECT vbelv vbeln posnn vbtyp_v
    FROM vbfa
    INTO TABLE l_i_vbfa
    FOR ALL ENTRIES IN l_i_bill_cs
    WHERE vbeln EQ l_i_bill_cs-vbeln
    AND posnn EQ '000010'
    AND vbtyp_n IN ('K', 'H'). "MOD-024--
    AND vbtyp_v IN ('K', 'H'). "MOD-024++
    SORT l_i_vbfa BY vbeln vbtyp_n.
    Regards,
    Naidu
    Moderator message: third time I have to remind you: for performance problems with VBFA table please search for previous discussions of the same topic
    Edited by: Thomas Zloch on Nov 9, 2010 12:41 PM

    Hi Naidu,
    ranges: r_vbtypv type vbfa-r_vbtyp_v.
      CLEAR r_vbtypv.
      r_vbtypv-option = 'EQ'.
      r_vbtypv-sign   = 'I'.
      r_vbtypv-low    = 'K'.
      APPEND r_vbtypv.
      CLEAR r_vbtypv.
      r_vbtypvl-option = 'EQ'.
      r_vbtypv-sign   = 'I'.
      r_vbtypv-low    = 'H'.
      APPEND r_vbtypv.
    sort l_i_bill_cs by vbenl.
    if not l_i_bill_cs[] is initial.
    SELECT vbelv vbeln posnn vbtyp_v
    FROM vbfa
    INTO TABLE l_i_vbfa
    FOR ALL ENTRIES IN l_i_bill_cs
    WHERE vbeln EQ l_i_bill_cs-vbeln
    AND posnn EQ '000010'
    AND vbtyp_v IN r_anlkl.
    endif.
    SORT l_i_vbfa BY vbeln vbtyp_n.
    Thanks,
    Nelson

Maybe you are looking for