How display number of row in select statement

How can I display number of row in select statement?
Table
data1 data2
xxx ccd
wss qwe
qws uij
I need get from SELECT statement:
1 xxx ccd
2 wss qwe
3 qws uij

user13734495 wrote:
Thank you from answer.
Statement
select rownum rn, data1, data2 from table
is good.
And what have I do went I use
select rownum rn, data1, data2 from table order by data1
and I get
3 qws uij
2 wss qwe
1 xxx ccd
I need
1 qws uij
2 wss qwe
3 xxx ccdhence the importance of describing the complete problem.
select
  rownum,
  data1,
  data2
from(
  select
    data1,
    data2
  from
    table
  order by
    data1)

Similar Messages

  • How to display number of rows as columns in a select statement? This is on

    How to display number of rows as columns in a select statement? This is on 10g R2.
    Thanks,
    R

    For the current (ie. row 1 of 100)
    row_number over (order by -pick_a_column_set) as rnfor the total number of columns returned in your query
    count(*) over() as total_count

  • How to make first row as selected in af:table

    Hi,
    I am using JDeveloper 11.1.1.4 and ADF-BC in my application.
    In all the pages across my application we have multi select enabled for the table[af:table].
    But when the pages are displayed,the first row is not selected by default.
    My requirement is to display first row as selected across all the tables in my app.
    I have the selectionListenerset as for example selectionListener="#{bindings.RSCMapVO2.collectionModel.makeCurrent}" in all the pages.
    Please suggest on how to make first row as selected.
    Regards,
    Praveen

    Hi
    Put these codes in your selection listner method(You have to define a selectionListner method in your backing bean and put this code segment
    (Special thanks go to Franks how posted this code segment. threadID=1089583)
    RichTable yourTable = (RichTable) selectionEvent.getSource();
    //the Collection Model is the object that provides the structured data
    //for the table to render
    CollectionModel yourTableModel = (CollectionModel) yourTable.getValue();
    //the ADF object that implements the CollectionModel is JUCtrlHierBinding. It
    //is wrapped by the CollectionModel API
    JUCtrlHierBinding yourTableBinding = (JUCtrlHierBinding) yourTableModel.getWrappedData();
    //Acess the ADF iterator binding that is used with ADF table binding
    DCIteratorBinding yourTableIteratorBinding = yourTableeBinding.getDCIteratorBinding();
    //the role of this method is to synchronize the table component selection
    //with the selection in the ADF model
    Object _selectedRowData = yourTable.getSelectedRowData();
    //cast to JUCtrlHierNodeBinding, which is the ADF object that represents
    //a row
    JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding) selectedRowData;
    //get the row key from the node binding and set it as the current row in the
    //iterator
    Key rwKey = nodeBinding.getRowKey();
    tableIteratorBinding.setCurrentRowWithKey(rwKey.toStringFormat(true));
    Thanks
    Padma

  • What is the use of additon in up to 1 rows in SELECT statement

    Hi All,
             What is the use of up to 1 rows in select statement.
    for example
    SELECT kostl
          FROM pa0001
          INTO y_lv_kostl UP TO 1 ROWS
          WHERE pernr EQ pernr
          AND endda GE sy-datum.
        ENDSELECT.
    I'm unable to get in wat situations we hav to add up to 1 rows
    please help me out...
    Thanks,
    santosh.

    Hi,
    Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for.
    The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.
    The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.
    Regards,
    Bhaskar

  • How to call user fuction in select statement.

    hi,
    i am facing some problem.How to call user functions in select statement.please send me answer with example.
    Thanks
    Gopal

    Locations to Call User-Defined Functions
    • Select list of a SELECT command
    • Condition of the WHERE and HAVING clauses
    • CONNECT BY, START WITH, ORDER BY, and GROUP
    BY clauses
    • VALUES clause of the INSERT command
    • SET clause of the UPDATE command
    Restrictions on Calling Functions from SQL Expressions
    To be callable from SQL expressions, a user-defined
    function must:
    • Be a stored function
    • Accept only IN parameters
    • Accept only valid SQL data types, not PL/SQL
    specific types, as parameters
    • Return data types that are valid SQL data types,
    not PL/SQL specific types
    • Functions called from SQL expressions cannot
    contain DML statements.
    • Functions called from UPDATE/DELETE statements
    on a table T cannot contain DML on the same table
    T.
    • Functions called from an UPDATE or a DELETE
    statement on a table T cannot query the same table.
    • Functions called from SQL statements cannot
    contain statements that end the transactions.
    • Calls to subprograms that break the previous
    restriction are not allowed in the function.
    jeneesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to put OR clause in SELECT statement

    Hi
    How to put OR clause in SELECT statement to return number_first/number_last to match records from another table's column.
    <pre>
    SELECT
    a.id ,
    flat_number ||' '|| a.number_first||' '||a.street_name||' '||a.suburb address1,
    apt_no ||' '|| street_no||' '||b.street_name||' '||b.suburb address2
    from
    a ,
    b
    where b.street_name = a.street_name
    AND b.SUBURB = a.SUBURB
    AND b.STATE = a.STATE
    </pre>
    Thsi will return this as exact match.
    ADDRESS 1
    12 TAMAN TENANG A ORCHARD 3142     
    10 RAMA YISHUN 2095
    ADDRESS2
    12 TAMAN TENANG A ORCHARD 3142     
    10 RAMA YISHUN 2095
    However this only matches number_first.
    How can I get the query work that it will match both number_first and number_last (table b)in address 1 to match street_no in address2 ( table b).My oracle version is 10GR/2.

    Hi, I have a hard time understanding your request, and below is what I thought you want:
    SELECT
        a.id ,
           flat_number ||' '|| (decode(b.street_no, a.number_first, a.number_first, a.number_last, a.number_last)||' '||a.street_name||' '||a.suburb  address1,
             apt_no ||' '|| street_no||' '||b.street_name||' '||b.suburb address2
          from
                 a ,
                 b
                where          b.street_name = a.street_name
                 AND            b.SUBURB      = a.SUBURB
                AND            b.STATE       = a.STATE
                AND  (B.street_no=a.number_first OR b.street_no=a.number_last);Not tested.
    Also, since your B.street_no will be either a.number_first OR a.number_last, you could replace
    (decode(b.street_no, a.number_first, a.number_first, a.number_last, a.number_last) with just b.street_no.
    Edited by: PhoenixBai on Aug 26, 2010 11:33 AM

  • How to customize some rows default selected in tableSelectMany

    Hi all,
    How to set some rows default selected in tableSelectMany
    Thanks
    Jayson

    If you bind table to managed bean attribute using binding property you may preselect some rows in getter of that attribute.
    private RichTable _t;
    public RichTable get_t() {
        //select few rows here or all...
        _t.getSelectedRowKeys().addAll();
        return _t;
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to Display Number of Rows Deleted/Inserted etc... in PL/SQL

    In Oracle 10g PL/SQL, I have a delete statement in a stored procedure. It is not in a cursor. I want to see the number of rows I've deleted. I can use the dbms_output.put_line package. I should know this, but I don't have time to perfect the syntax. How would I get the number of rows that get deleted and display it via dbms_output.put_lline?

    No time to google either I guess.
    http://www.google.co.uk/search?q=number+of+rows+deleted+oracle&rls=com.microsoft:en-gb&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1&rlz=&redir_esc=&ei=Qi5qToGyGYqw8QOGzf3nAg
    SQL> create table dt_del_ex(id number);
    Table created.
    SQL> set serveroutput on
    SQL> BEGIN
      2
      3      INSERT INTO dt_del_ex VALUES(1);
      4
      5      DBMS_OUTPUT.put_line(TO_CHAR(SQL%ROWCOUNT)||' rows inserted');
      6
      7      INSERT INTO dt_del_ex select rownum from dual connect by level <=10;
      8
      9      DBMS_OUTPUT.put_line(TO_CHAR(SQL%ROWCOUNT)||' rows inserted');
    10
    11      UPDATE dt_del_ex SET id = id + 3 WHERE id >= 9;
    12
    13      DBMS_OUTPUT.put_line(TO_CHAR(SQL%ROWCOUNT)||' rows updated');
    14
    15      DELETE FROM dt_del_ex WHERE id <= 10;
    16
    17      DBMS_OUTPUT.put_line(TO_CHAR(SQL%ROWCOUNT)||' rows deleted');
    18
    19  END;
    20  /
    1 rows inserted
    10 rows inserted
    2 rows updated
    9 rows deleted
    PL/SQL procedure successfully completed.

  • Limit rows in select statement

    Hi,
    we have the following SQL select statement in an extension in our CMS system
    var newConn = new openConnection();
    if(request.searchBox)
         var searchBox = request.searchBox;
         var keywords = searchBox.split(' ')
         var sql = 'SELECT forumID, masterID, subject, message, datePosted FROM THREADS WHERE approved=1'
         for(var i=0; i<keywords.length; i++)
              sql += ' AND UPPER(subject) LIKE UPPER(\'%' + keywords[i] + '%\')'
              sql += ' OR UPPER(message) LIKE UPPER(\'%' + keywords[i] + '%\')'
         sql          += ' ORDER BY datePosted DESC;';
    else {
         document.write("No results found");
    var result = newConn.execute(sql);
    var counter = 0;
    while(result && (counter < 5 || request.searchBox))
         ascii_nextCol(result[0]);                                             //Datafield 0 Forum ID
         ascii_nextCol(result[1]);                                             //Datafield 1 Master ID
         ascii_nextCol(result[2]);                                             //Datafield 2 Subject
         ascii_nextCol(result[3]);                                             //Datafield 3 Message
         ascii_nextCol(dateFormatter.format(result[4]));                    //Datafield 4 Date posted     
         ascii_nextRow();
         result = newConn.nextRow();
         counter++;
    closeConnection(newConn);
    ascii_update();
    There are a couple of issues with it though, this bit doesn't work when no results are returned:
    else {
         document.write("No results found");
    And I want to limit the number of rows to 50.
    Someone mentioned that "ROWCOUNT" could be the answer to both problems but I have no idea where it should go or how to write it into this code. I've tried Googling for an answer without much luck as I don't know a great deal about this coding.
    Can anyone help?

    Aga wrote:
    Try adding
    sql += ' AND rownum < 51'
    before
    sql += ' ORDER BY datePosted DESC;';
    It will limit the number of rows to 50.If you limit by rownum and order in the same query you are ordering 50 random rows of the query.
    you should order in a subquery before using rownum to get only the top results.
    Processing ...
    with t as (
         select 120 as val from dual
         union all
         select -5 as val from dual
         union all
         select 45 as val from dual
         union all
         select 3 as val from dual
         union all
         select 1258 as val from dual
         union all
         select 874552 as val from dual
         union all
         select -1452 as val from dual
         union all
         select 0 as val from dual
    select *
    from t
    where rownum <= 3
    order by val
    Query finished, retrieving results...
                      VAL                 
                                        -5
                                        45
                                       120
    3 row(s) retrieved
    Processing ...
    with t as (
         select 120 as val from dual
         union all
         select -5 as val from dual
         union all
         select 45 as val from dual
         union all
         select 3 as val from dual
         union all
         select 1258 as val from dual
         union all
         select 874552 as val from dual
         union all
         select -1452 as val from dual
         union all
         select 0 as val from dual
    select *
    from (
              select *
              from t
              order by val
    where rownum <= 3
    Query finished, retrieving results...
                      VAL                 
                                     -1452
                                        -5
                                         0
    3 row(s) retrievedBye Alessandro

  • Report to display number of items sold by state

    Hello experts,
    I would need a report with the following paramters:
    Deliver doc number,posting date,ship to state,item number,item desc,quantity.Is it possible to have the selection for the date range?
    Thanks

    Hello Gordon,
    This is what I noticed.
    This query shows the ship to state for the order if they are not on the User defined fields on a delivery document.
    Let me be more clear
    This query is displaying only the customers where the ship to address is entered in the BP master data.If the ship to address is entered at the sales order level it is not displaying the ship to state.
    I hope this makes sense
    Thanks

  • How user variable table names in select statement

    Dear all,
    I have three table gp1,gp2,g3. i want user variable table in sql query
    for example at oracle forms have a list table showing table names gp1,gp2,gp3
    at form i want user this query
    select gpno from :table where gpno=120;
    how i can specify table name Dynamicly in select query
    Thanks

    Forms_DDL is a one-way street: You can only pass DDL commands TO the database; you cannot get data back using Forms_DDL.
    Exec_SQL is the Forms package that enables dynamic sql within a form. But to retrieve data, you have to make a Exec_SQL call for every column in every row. So it is not a good thing to use, either.
    The ref cursor method should work. You could also retrieve the data into a record group using populate_group_with_query -- it also enables dynamic data retrieval.
    But if you already know you have three distinct tables and you know their names, I would keep it simple and just write three sql select statements.

  • Delete adjacent duplicates how to use in the below select statement

    hi i have a problem
    i am suing the below select statement
    SELECT    a~extno
              a~guid_lclic       " for next select
              e~ctsim
              e~ctsex
    *revised spec 3rd
              f~guid_pobj
              f~amnt_flt
              f~amcur
              f~guid_mobj
              e~srvll     "pk
              e~ctsty     "PK
              e~lgreg  "PK
      INTO TABLE gt_sagmeld
      FROM /SAPSLL/LCLIC  as a
      INNER JOIN /sapsll/tlegsv as e on elgreg = algreg
      inner join /sapsll/legcon as f on fguid_lclic = aguid_lclic   " for ccngn1 selection
      inner join /sapsll/corcts as g on gguid_pobj = fguid_pobj
                               where   a~extno in s_extno.
      sort gt_sagmeld by guid_lclic lgreg ctsty srvll GUID_POBJ GUID_MOBJ.
      delete adjacent duplicates from gt_sagmeld comparing guid_lclic lgreg ctsty srvll GUID_POBJ GUID_MOBJ .
    now i am confused how to use delete adjacent dupliacate and on which fields
    as first table /sal../lclic primary key is guid_lclic
    and it is joined to table
    legcon by guid_lclci ( not a primary key here)
    legcon primary key is guid_legcon
    and table 3 legsv by lgreg (pk here)
    table 3 has tow more primary key srvll and ctsty also
    NOW MY QUESTIO IS TAHT IS I USE ABOVE DELETE ADJACENT STATMENT IT FETCHES 20 LAKH RECORDS
    I WANT TO REDUCE IS LET ME KNOW ON WHAT fields i need to use delete adjacen duplicates
    or use comparing all fields?
    regards
    Arora

    hi sudha
    if u see my select statement is contains four Primary keys
    srvll
    lgreg
    ctsty
    guid_lclic
    but the next table connected to this table legcon is by guid_pobj and anothe table by guid_mobj
    and if i take this gt_sagmeld to another temp table and i find abt 10 lakh uniques guid_pobj
    similary 6 lakh guid_mobj so the next slect is hanpering because of this
    not COMING TO OUR POINT IF I SORT ONLY BY OUR PRIMARY KEYS NOT TAKING INTO ACCOUNT TEH GUID_POBJ AND GUID_MOBJ
    THE ENTRIES ARE VERY LESS BUT IF I TAKE INOT ACCCOUNT IN GT_SAGMELD THE ENTRIES ARE ABT 20 LAKH
    SO I AM NOT SURE WHETHER TO TAKNE GUID_POBJ AND GUID_MOBJ INOT ACCOUNT FOR DELECTING ADJACENT DUPLICATES?
    HENCE THE QUESTION OF ON WHICH FIRLD DELETE OR COMPARING ALL FIELDS I USE?

  • How to insert variable value using select statement - Oracle function

    Hi,
    I have a function which inserts record on basis of some condition
    INSERT INTO Case
    Case_ID,
    Case_Status,
    Closure_Code,
    Closure_Date
    SELECT newCaseID,
    caseStatus,
    Closure_Code,
    Closure_Date,
    FROM Case
    WHERE Case_ID = caseID
    Now i want new casestatus value in place of select statement caseStatus value. I have a variable m_caseStatus and i want to use the value of this variable in above select statement.
    how can i use this.
    thanks

    Hi,
    I have a function which inserts record on basis of some condition
    INSERT INTO Case
    Case_ID,
    Case_Status,
    Closure_Code,
    Closure_Date
    SELECT newCaseID,
    caseStatus,
    Closure_Code,
    Closure_Date,
    FROM Case
    WHERE Case_ID = caseID
    Now i want new casestatus value in place of select statement caseStatus value. I have a variable m_caseStatus and i want to use the value of this variable in above select statement.
    how can i use this. Do not select Case_Status from inner select, so null will be inserted then after inserting it update the case status with m_caseStatus.
    Regards.

  • How to make some rows not selectable in AdvancedDataGrid

    Hi there,
    I have an advanced data grid which allows to select multiple rows. I need to make certain rows not selectable dependent on the row data. How can this be done?
    Help is greatly appreciated. Thanks in advance.
    --Charmaine

    Hi, You can view same demo here
    Thanks and Best regards,
    Pallavi Joshi | [email protected] | www.infocepts.com

  • How to avoid the below nested select statement

    Please any one help me how this select statemet is working and      how to avoid the nesetd select statement .
    if we avoid below nested , does it improve performace ?
    select field1 field2                                  
               into table w_feeds                                 
               from ZTable as t                         
               where field2 in r_feedf1                       
               and  POSITION_POSTDT =                           
               ( SELECT MAX( position_postdt ) FROM zTable 
                      where position_postdt le r_pdate-high    
                      and   field1 = t~field1 ).
    Thanks in Advace.

    Hi,
    Instead of nested query go for two separate queries. I see you are querying on the same table...so better go by this approach
    select field1 field2 POSITION_POSTDT
    into table w_feeds
    from ZTable
    where field2 in r_feedf1.
    Remove the where condition on POSITION_POSTDT
    Sort the table w_feeds by POSITION_POSTDT  Descending; So you will get data pertaining to Max Position_Postdt.
    Finally delete the other entries which are not Max.
    This will enhance the performance over the nested query.
    Regards
    Shiva
    Edited by: Shiva Kumar Tirumalasetty on Apr 27, 2010 7:00 PM
    Edited by: Shiva Kumar Tirumalasetty on Apr 27, 2010 7:00 PM

Maybe you are looking for

  • How do I sync my gmail contacts with the contacts already on my iPhone?

    I just bought an iPhone 5c and the dealer manually transferred all of my (gmail) contacts from my Samsung Galaxy.  Now the contacts on my iPhone are no longer synced with my gmail account.  If I make changes to a contact on my iPhone, that change doe

  • Automount in Gnome 3.4.1 is broken

    Hi all! I have a strange issue with gnome 3.4.1 and automount on both my laptop and my PC. When I plug an usbkey, I can hear the sound "plop" but nothing happen, no notification to open nautilus, and in nautilus, the usb device isn't showed, isn't mo

  • E540 Black screen

    Hello, I have E540 with i3 few days. Problem with black screen appeared on third day. Laptop normally run and suddenly screen was black. When I disconnect power plug, screen is fine. I've found when I disable lowing refresh rate on battery in intel s

  • Bapi_pr_change with blocked field

    Hello, I blocked the purchase request when i created it. Now I need to open it via the Bapi_pr_change  ,so I filled the following fields: <b>Import:NUMBER = my number Tables:PRITEM  :PREQ_ITEM=00010 , REQ_BLOCKED =(none),           PRITEMX:PREQ_ITEM=

  • Why I can't receive e-mail anymore on my iPad

    Hi can someone tell me why my iPad has stopped receiving e-mail?