Needs  help to retrive the last row in a  select query without using rownum

Hi ,
i need to retrive the last row from the select sub query without using rownum.
is there any other way to retrive the last row other than the below query.
is that the ROWNUM=1 will always retrive the 1 row of the select query ?
select from*
*(select ename from employee where dept_id=5 order by desc) where rownum=1;*
Please advise.
thanks for your help advance,
regards,
Senthur

957595 wrote:
Actually my problem is ithat while selecting the parents hiearchy of the child data using
CONNECT BY PRIOIR query
I need the immediate parent of my child data.
For example my connect BY query returns
AAA --- ROOT
BBB --PARENT -2
CCC --PARENT-1
DDD IS my input child to the connect by query
Immediate parent of my child data "DDD" ---> CCC(parent -1)
i want the data "CCC" from the select query,for that i am taking the last row of the query with rownum.
I got to hear that using ROWNUM to retrive the data will leads to some problem.It is a like a magic number.I am not sure what the problem will be.
So confusing with using this rownum in my query.
Please advice!!!It's not quite clear what you're wanting, but perhaps this may help?
you can select the PRIOR values to get the parent details if you want...
SQL> ed
Wrote file afiedt.buf
  1  select empno, lpad(' ',(level-1)*2,' ')||ename as ename, prior empno as mgr
  2  from emp
  3  connect by mgr = prior empno
  4* start with mgr is null
SQL> /
     EMPNO ENAME                                 MGR
      7839 KING
      7566   JONES                              7839
      7788     SCOTT                            7566
      7876       ADAMS                          7788
      7902     FORD                             7566
      7369       SMITH                          7902
      7698   BLAKE                              7839
      7499     ALLEN                            7698
      7521     WARD                             7698
      7654     MARTIN                           7698
      7844     TURNER                           7698
      7900     JAMES                            7698
      7782   CLARK                              7839
      7934     MILLER                           7782
14 rows selected.(ok, not the best of examples as the mgr is already known for a row, but it demonstrates you can select prior data)

Similar Messages

  • Need help on displaying the callers name on ip phone with cme using external directory

    Hello Guys,
    Need help on displaying the callers name on ip phone with cme while using external directory
    Thank you,
    Khaja

    Thanks for your help,
    Does it 100% work with CME. We use SIP and 2ring for external directory?  Thanks you.

  • How to Finding the Last Row Value in Datagrid?

    Hi Everyone,
    Thanks in Advance.
    I need your help, to find the last row data in Datagrid.
    Actually i am using Datagrid to display my Data in flex. In my data i stored the gender value of employees. So if the last row in my datagrid is "female" i need to be highlight that particular row. So please help me to solve this issue.
    Thanks,
    Charles. J

    datagrid.selectedIndex = datagrid.dataprovider.length;
    ^ something like this will select the last row in the datagrid.
    if you need to check it's value, you might need to cast an object here, based on the index value, and check it's gender value.
    datagrid.selectedIndex = datagrid.dataprovider.length;
    if (datagrid.selectedItem["gender"] == "female") {
    //handle here

  • JTable cell Render on the last row column one help please

    Hi All
    I am hoping that someone will be able to help me with this....
    I want to render the last row and column one of the table with this render
    thanks for any help
    Craig
        public class MyRenderer2 extends DefaultTableCellRenderer {
            public Component getTableCellRendererComponent(JTable table,
                    Object value,
                    boolean isSelected, boolean hasFocus,
                    int row, int column) {
                ImageIcon icon = new ImageIcon(image_pics.SMALL_BLUE);
                setIcon(icon);
                return this;
        }

    it still renders every row
    any Ideas ??
    I just want the last row column 0 to be rendered
    I a call a method set table
    then I call for the data
    //TableModel
        public void setClientTableModel() {
            clientModel = new DefaultTableModel(coloumHeaderObject, 0) {
                public boolean isCellEditable(int row, int column) {
                    return false;
            TableSorter sorter = new TableSorter(clientModel); //ADDED THIS
            sorter.setTableHeader(phoneList.getTableHeader()); //ADDED THIS
            phoneList.setModel(sorter);
           // phoneList.setTableHeader(null);
            setTable();
            revalidate();
        public void setTable() {
          // phoneList.getColumnModel().getColumn(0).setCellRenderer(new MyRenderer());
            phoneList.getColumnModel().getColumn(1).setCellRenderer(new MyRenderer1());
            phoneList.getColumnModel().getColumn(4).setCellRenderer(new MyRenderer2());
            phoneList.getColumnModel().getColumn(0).setMinWidth(20);
            phoneList.getColumnModel().getColumn(0).setMaxWidth(20);
            phoneList.getColumnModel().getColumn(0).setPreferredWidth(20);
            phoneList.getColumnModel().getColumn(1).setMinWidth(20);
            phoneList.getColumnModel().getColumn(1).setMaxWidth(20);
            phoneList.getColumnModel().getColumn(1).setPreferredWidth(20);
            phoneList.getColumnModel().getColumn(2).setMinWidth(80);
            phoneList.getColumnModel().getColumn(2).setMaxWidth(80);
            phoneList.getColumnModel().getColumn(2).setPreferredWidth(80);
            phoneList.getColumnModel().getColumn(3).setMinWidth(150);
            phoneList.getColumnModel().getColumn(3).setMaxWidth(150);
            phoneList.getColumnModel().getColumn(3).setPreferredWidth(150);
            phoneList.getColumnModel().getColumn(4).setMinWidth(20);
            phoneList.getColumnModel().getColumn(4).setMaxWidth(20);
            phoneList.getColumnModel().getColumn(4).setPreferredWidth(20);
            phoneList.setOpaque(false);
            phoneList.setGridColor(Color.lightGray);
            phoneList.setRowHeight(18);
            phoneList.setShowVerticalLines(false);
            phoneList.setIntercellSpacing(new Dimension(0, 0));
            phoneList.setFont(new java.awt.Font("Lucida Grande", 0, 11));
            phoneList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            if (ALLOW_COLUMN_SELECTION) { // false by default
                if (ALLOW_ROW_SELECTION) {
                    phoneList.setCellSelectionEnabled(true);
                phoneList.setColumnSelectionAllowed(true);
                ListSelectionModel colSM = phoneList.getColumnModel().getSelectionModel();
                colSM.addListSelectionListener(new ListSelectionListener() {
                    public void valueChanged(ListSelectionEvent e) {
                        if (e.getValueIsAdjusting())return;
                        ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                        int row = phoneList.getSelectedRow(), col = 3;
                        int rowID = phoneList.getSelectedRow(), colID = 5;
                        if (lsm.isSelectionEmpty()) {
                        } else {
                            int selectedCol = lsm.getMinSelectionIndex();
                            if (selectedCol == 4) {
                                phoneNumber = (String) phoneList.getValueAt(row, col).toString();
                                main.setPhoneNumber(phoneNumber);
                                main.openLargePhone();
                                lsm.clearSelection();
                            if (selectedCol == 5) {
                                ID = (String) phoneList.getValueAt(row, col).toString();
                             //   main.setID(ID);
                              //  main.deleteContact();
                                lsm.clearSelection();
    //set table data
        public void setTest() {
            setClientTableModel();
            Object[] data = {" ", " ", "Work", "03 9841-8247", " "};
            clientModel.addRow(data);
            Object[] data1 = {" ", " ", "Fax", "03 9842-0360", " "};
            clientModel.addRow(data1);
            phoneList.getColumnModel().getColumn(0).setCellRenderer(new MyRenderer());
        }

  • HELP! How te retrieve the last row in MYSQL database using Servlet!

    Hi ,
    I am new servlets. I am trying to retireve the last row id inserted using the servlet.
    Could someone show me a working sample code on how to retrieve the last record inserted?
    Thanks
    MY CODE
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class demo_gr extends HttpServlet {
    //***** Servlet access to data base
    public void doPost (HttpServletRequest req, HttpServletResponse resp)
         throws ServletException, IOException
         String url = "jdbc:mysql://sql2.njit.edu/ki3_proj";
              String param1 = req.getParameter("param1");
              PrintWriter out = resp.getWriter();
              resp.setContentType("text/html");
              String semail, sfname, slname, rfname, rlname, remail, message;
              int cardType;
              sfname = req.getParameter("sfname");
              slname = req.getParameter("slname");
              rfname = req.getParameter("rfname");
              rlname = req.getParameter("rlname");
              semail = req.getParameter("semail");
              remail = req.getParameter("remail");
              message = req.getParameter("message");
              //cardType = req.getParameter("cardType");
              cardType = Integer.parseInt(req.getParameter("cardType"));
              out.println(" param1 " + param1 + "\n");
         String query = "SELECT * FROM greeting_db "
    + "WHERE id =" + param1 + "";
              String query2 ="INSERT INTO greeting_db (sfname, slname ,semail , rfname , rlname , remail , message , cardType ,sentdate ,vieweddate) values('";
              query2 = query2 + sfname +"','"+ slname + "','"+ semail + "','"+ rfname + "','"+ rlname + "','"+ remail + "','"+ message + "','"+ cardType + "',NOW(),NOW())";
              //out.println(" query2 " + query2 + "\n");
              if (semail.equals("") || sfname.equals("") ||
              slname.equals("") || rfname.equals("") ||
              rlname.equals("") || remail.equals("") ||
              message.equals(""))
                        out.println("<h3> Please Click the back button and fill in <b>all</b> fields</h3>");
                        out.close();
                        return;
              String title = "Your Card Has Been Sent";
              out.println("<BODY>\n" +
    "<H1 ALIGN=CENTER>" + title + "</H1>\n" );
                   out.println("\n" +
    "\n" +
    " From  " + sfname + ", " + slname + "\n <br> To  "
                                            + rfname + ", " + rlname + "\n <br>Receiver Email  " + remail + "\n<br> Your Message "
                                            + message + "\n<br> <br> :");
                   if (cardType ==1)
                        out.println("<IMG SRC=/WEB-INF/images/bentley.jpg>");
                   else if(cardType ==2) {
                        out.println("<IMG SRC=/WEB-INF/images/Bugatti.jpg>");
                   else if(cardType ==3) {
                        out.println(" <IMG SRC=/WEB-INF/images/castle.jpg>");
    else if(cardType ==4) {
                        out.println(" <IMG SRC=/WEB-INF/images/motocross.jpg>");
    else if(cardType ==5) {
                        out.println(" <IMG SRC=/WEB-INF/images/Mustang.jpg>");
    else if(cardType ==6) {
                        out.println("<IMG SRC=/WEB-INF/images/Mustang.jpg>");
    out.println("</BODY></HTML>");
         try {
              Class.forName ("com.mysql.jdbc.Driver");
              Connection con = DriverManager.getConnection
              ( url, "*****", "******" );
    Statement stmt = con.createStatement ();
                   stmt.execute (query2);
                   //String query3 = "SELECT LAST_INSERT_ID()";
                   //ResultSet rs = stmt.executeQuery (query3);
                   //int questionID = rs.getInt(1);
                   System.out.println("Total rows:"+questionID);
    stmt.close();
    con.close();
    } // end try
    catch (SQLException ex) {
              //PrintWriter out = resp.getWriter();
         resp.setContentType("text/html");
              while (ex != null) { 
         out.println ("SQL Exception: " + ex.getMessage ());
         ex = ex.getNextException ();
    } // end while
    } // end catch SQLException
    catch (java.lang.Exception ex) {
         //PrintWriter out = resp.getWriter();
              resp.setContentType("text/html");     
              out.println ("Exception: " + ex.getMessage ());
    } // end doGet
    private void printResultSet ( HttpServletResponse resp, ResultSet rs )
    throws SQLException {
    try {
              PrintWriter out = resp.getWriter();
         out.println("<html>");
         out.println("<head><title>jbs jdbc/mysql servlet</title></head>");
         out.println("<body>");
         out.println("<center><font color=AA0000>");
         out.println("<table border='1'>");
         int numCols = rs.getMetaData().getColumnCount ();
    while ( rs.next() ) {
              out.println("<tr>");
         for (int i=1; i<=numCols; i++) {
    out.print("<td>" + rs.getString(i) + "</td>" );
    } // end for
    out.println("</tr>");
    } // end while
         out.println("</table>");
         out.println("</font></center>");
         out.println("</body>");
         out.println("</html>");
         out.close();
         } // end try
    catch ( IOException except) {
    } // end catch
    } // end returnHTML
    } // end jbsJDBCServlet

    I dont know what table names and fields you have but
    say you have a table called XYZ which has a primary
    key field called keyID.
    So in order to get the last row inserted, you could
    do something like
    Select *
    from XYZ
    where keyID = (Select MAX(keyID) from XYZ);
    Good Luckwhat gubloo said is correct ...But this is all in MS SQL Server I don't know the syntax and key words in MYSQL
    This works fine if the emp_id is incremental and of type integer
    Query:
    select      *
    from      employee e,  (select max(emp_id) as emp_id from employee) z
    where      e.emp_id = z.emp_id
    or
    select top 1 * from employee order by emp_id descUday

  • RFC - XI - JDBC(mapping only the last row of a record)

    Hello all,
    in a mapping response from an oracle base after a RFC call with a select statement, i have the following response :
    <StatementSelect_response>(cardinality 0..1)
    <row1>(cardinality 0..unbounded)
    <field1>1</field1>
    <field2>2</field2>
    </row1>
    <row2>
    <field1>3</field1>
    <field2>4</field2>
    </row2>
    </statement>
    i have to map those fields in a RFC_response like :
    <RFC_response>(0..1)
    <field1>
    <field2>
    </rfc _response>
    Problem : I only need to send back to the rfc_response the last records of my StatementSelect_response in order to have the following message :
    <RFC_response>
    <field1>3
    <field2>4
    </rfc _response>
    How can i select only the last row of my records plz ?
    Thanks by advance

    VJ wrote:>
    > Hi,
    >
    > public void LastRow(String[] a,ResultList result,Container container){
    >
    > int len = a.length();
    > Result.addValue(a\[len-1\]);
    >
    > }
    VJ,
    Please don't confuse him. If you want to update the thread, let me leave it aside.Coz it shouldn't cause him trouble. Can u check a.length() is correct? it has to be a.length, isn't it?
    We all here to help others, not under any motivation of compete..
    Sorry, if I hurt you..
    raj.

  • Get rows where the last row finish off

    Hi, i have two tables AND would LIKE TO get data BY combining both.
    here IS my data
    WITH hist AS
      SELECT To_Date('4/23/2010','mm/dd/yyyy') dt, 999 alias, 'PROC' dom FROM dual UNION ALL
      SELECT To_Date('4/27/2010','mm/dd/yyyy') dt, 999 alias, 'LON' dom FROM dual UNION all
      SELECT To_Date('4/1/2010','mm/dd/yyyy') dt, 111 alias, 'SOC' dom FROM dual UNION all
      SELECT To_Date('4/10/2010','mm/dd/yyyy') dt, 111 alias, 'NAO' dom FROM dual UNION ALL
      SELECT To_Date('3/23/2010','mm/dd/yyyy') dt, 222 alias, 'PSE' dom FROM dual
    final AS
      SELECT To_Date('2/26/2010','mm/dd/yyyy') dt, 999 alias FROM dual UNION ALL
      SELECT To_Date('4/22/2010','mm/dd/yyyy') dt, 999 alias FROM dual UNION all
      SELECT To_Date('4/26/2010','mm/dd/yyyy') dt, 999 alias FROM dual UNION ALL
      SELECT To_Date('4/30/2010','mm/dd/yyyy') dt, 999 alias FROM dual UNION ALL
      SELECT To_Date('2/25/2010','mm/dd/yyyy') dt, 111 alias FROM dual UNION ALL
      SELECT To_Date('2/26/2010','mm/dd/yyyy') dt, 222 alias FROM dual UNION ALL
      SELECT To_Date('4/22/2010','mm/dd/yyyy') dt, 222 alias FROM dual UNION all
      SELECT To_Date('4/26/2010','mm/dd/yyyy') dt, 222 alias FROM dual
    the output should be as follow(without the extra blank line of course)
    DT           ALIAS   DOM
    2/26/2010     999     PROC
    4/22/2010     999     PROC
    4/26/2010     999     LON
    4/30/2010     999     LON
    4/27/2010     999     LON
    4/23/2010     999     PROC
    2/25/2010     111     SOC
    4/1/2010     222     SOC
    4/10/2010     222     NAO
    2/26/2010     222     PSE
    4/22/2010     222     PSE
    4/26/2010     222     PSEso what i am doing here is as follow, take one row in hist table (4/23) and join with final table and give me all rows in final table
    where dt <= to the row in hist table and include the row from hist table.
    this logic will give me rows 2/26/2010,4/22/10 4/23/2010
    then the second row in hist table (4/27/2010) wiill get all rows
    in final table that is <= to the current row and pick up the rows starting from the row > than the last row where the 4/23/2010 finished off
    in this case the output will be 4/26/10, 4/27/2010(we need to include row from hist)
    since there is no row in hist that is greater than 4/30/2010, this date will still be display and dom column value should be taking from the max date in hist
    which is 4/27/2010. see output above
    this sound a little confusing to explain but look at output of what to expect as output. the other ids should follow the same logic
    can someone help write a query for this? thanks

    Hi,
    Devx wrote:
    Frank, thanks again, i ran the query in oracle 11g and oracle 9i. 11g runs ok but 9i doesnt. it looks like the ignore null option is not supported in 9i. That's right: IGNORE NULLS was new in Oracle 10. You should always mention your Oracle version whenever you ask a quiestion, especially if it's as old as Oracle 9.
    i will be running this query in 9i. is there any alternative to re-write this query without using last value since ignore null is not supported and the output is not as i expected when i take that keyword out.
    i really appreciate your help. please let me know how would i re-write the query. thanksOne work-around is to use LEAD or LAG instead of LAST_VALUE. This means you have to know exactly where (how many rows away) the most recent non-NULL value is, which in turn requires other analytuic funtions, such as ROW_NUMBER, and more sub-queries:
    WITH     combined_tables        AS
         SELECT     dt, alias, NVL (dom, '_?_') AS dom     FROM hist
         UNION
         SELECT     dt, alias, NULL          AS dom      FROM final
    ,     got_r_num     AS
         SELECT     dt, alias, dom
         ,     ROW_NUMBER () OVER ( PARTITION BY  alias
                                   ORDER BY          dt
                           )               AS r_num
         ,     COUNT (*)     OVER ( PARTITION BY  alias
                           )               AS alias_cnt
         FROM    combined_tables
    ,     got_skip_cnts     AS
         SELECT     dt, alias, dom, r_num
         ,     r_num - MAX (CASE WHEN dom IS NOT NULL THEN r_num END)
                                 OVER ( PARTITION BY  alias
                               ORDER BY          r_num
                             )                    AS skip_before
         ,     MIN (CASE WHEN dom IS NOT NULL THEN r_num END)
                                 OVER ( PARTITION BY  alias
                               ORDER BY          r_num     DESC
                             ) - r_num               AS skip_after
         FROM    got_r_num
    ,     got_next_dom     AS
         SELECT     dt, alias, dom, r_num, skip_before
         ,     LEAD (dom, skip_after) OVER ( PARTITION BY  alias
                                                ORDER BY      r_num
                                 ) AS next_dom
         FROM    got_skip_cnts
    SELECT       dt
    ,       alias
    ,       NULLIF ( COALESCE ( next_dom
                            , LAG (dom, skip_before) OVER ( PARTITION BY  alias
                                                         ORDER BY         r_num
               )     AS dom
    FROM       got_next_dom
    ORDER BY  alias
    ,            dt
    ;You should be able to calculate bot LEAD and LAG in the same query, but there seems to be a bug that only calculates one of them correctly in this case. The sub-query got_next_dom gets around that, by doing the LEAD in a separate sub-query.

  • How to get the last row of a database table.

    HI ,
    I want to get record exactly from the last row of a database table.
    How is that possible?

    Hi,
    To fetch last record from an internal table, just do find the number of records in it and read using index.
    DESCRIBE TABLE ITAB LINES L_LINES.
    READ TABLE ITAB INDEX L_LINES.
    You can also use LOOP .. ENDLOOP but the above method is better (performance wise).
    using LOOP .. ENDLOOP.
    LOOP AT ITAB.
    **do nothing
    ENDLOOP.
    **process ITAB (Header record of ITAB).
    **after ENLOOP, ITAB will have the last record of the internal table.
    [here ITAB is internal table as well as header record.]
    But what is the requirement?
    If you are looking for the current record of an employee then you can use ENDDA = HIGH_DATE.
    My advice is to review your requirement again and try to fetch only that record which you need.
    Mubeen

  • Help on retriving the content from a excel file and web page

    hi,
    i need help on identify the content on a webpage. how to do this ?
    in myproject i need to read an excel file how to read an excel file , in java?
    after reading the excel file ,i have to open a webpage based on the link available in the excel file.
    how to perform this action?
    and from the web page i need to retrive the each individual text
    how to perform these action?
    please help .... urgent
    regards,
    valli

    sales team will enter data in excel file .
    the excel file will have a list of links ,
    i need to access the excel file and open that link.
    from the link i will get some information ,such as
    company name, address, phone no, contact details.
    i need to identify each individual (address, email
    id) from the web page and store that data in the data
    base .
    how to access a excel file from java?
    i found in google jakartha-poi-jar file.
    but ther eare many jar file. which one i have to
    download?
    how to identify from a web page these different
    items?
    thanksPlease answer DrClaps's question from reply #3.

  • Hiding bloc of Lines in a web template in the last row

    Hello,
    I want to hide a bloc of lines in a web query.
    Here I use the table interface with the method
    characteristic cell according to the "How to" - paper
    (How to hide a column).
    Normally , there is no problem to set the tag
    '<!--' in the first column ot the row to be suppressed and the tag
    '-->' in the first column of the row, I want to display again.
    But the problem is the last row. Here I must close the
    tag in the last column of the last row. The effect is
    something like a double line at the end of the output.
    (I think, I see here another time the first column of
    a row, because I cannot close the tag properly)
    As a result, I have problems with the print manager, we use to enhance the web printing.
    Can someone give me the information, how to close the tag
    in a proper way at the last row.
    Many thanks for your help.
    Regards
    Ralph

    Hi,
    I don't think this is possible. I would try to use c_cell_extend to extend the style of each <td>-Tag with style="visibility:hidden; display:none" This should have the same affect (for all cells which have to be hidden) (depending on your table styles there might be some padding or spacing effects; you have to try this out).
    Heike

  • To find out the last row that is updated in a View Object

    Hi OAF Gurus,
    I have requirement like,
    I have to find out the last row that is updated on a particular View Object and I have send a mail to the users about the change.
    JegSAMassMobVOImpl vo = getJegSAMassMobVO1();
    JegSAMassMobVO is the View Object Name and it displays certain rows that has already been added to the VO in the Page.
    Now the issue is when a user updates a particular row,I have to find which row gets updated and have to send a email to that particular employee about the change.
    Just want to know,how to find out the last updated row in a particular VO.
    Any Help would be appreciated as this a immediate requirement.
    Regards,
    Magesh.M.K.
    Edited by: user1393742 on May 4, 2011 1:06 AM

    Hi Magesh
    It shoud be a Advanced table ,so when user will update the row ,the specific row will fire the PPR and on that event u can capture the row using row reference ,this is the sample code below
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean); OAApplicationModule am =
    (OAApplicationModule)pageContext.getApplicationModule(webBean);
    String event = pageContext.getParameter("event");
    if ("<ItemPPREventName>").equals(event))
    // Get the identifier of the PPR event source row
    String rowReference =
    pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
    Serializable[] parameters = { rowReference };
    // Pass the rowReference to a "handler" method in the application module.
    262
    am.invokeMethod("<handleSomeEvent>", parameters);
    In your application module's "handler" method, add the following code to access the source row:
    OARow row = (OARow)findRowByRef(rowReference);
    if (row != null)
    Thanks
    Pratap

  • Need help in finding the number of occurrences of a pattern.

    Hi All,
    I need help in finding the number of occurrences of a pattern in a table's column's data.
    Consider sample data - one row's column from a table:
    "S-S-S-A-S-S-P-S-S-B-S-A-P-S-S-C"
    My requirement is:
    I should get the count of S's which are immediately preceded by A or P.
    for the above data i should get count as 3+2+1=6 (S-S-S-A, S-S-P, S-A)
    The pattern data is stored as VARCHAR2 type.
    Thanks in advance,
    Girish G
    Edited by: Girish G on Jul 21, 2011 11:22 PM

    I am sure there exists a better way then this one:
    SQL> with dt as
      2  (select 'S-S-S-A-S-S-P-S-S-B-S-A-P-S-S-C' str from dual)
      3  SELECT SUM(Regexp_count(Regexp_substr(str, '(S\-?)+(A|P)+', 1,
      4                                     Regexp_count(str, '(S\-?)+(A|P)+') - (
      5                                                  LEVEL - 1 )), 'S')) len
      6  FROM   dt
      7  CONNECT BY LEVEL <= Regexp_count(str, '(S\-?)+(A|P)+')
      8  /
           LEN
             6

  • Insert a button on the last row of a report

    Hi all,
    my client wants an "add" button on the last row of any report that he has. I can do it easy on the first row (SELECT DECODE(rownum,1,'button','')), but I couldn't find a solution for this situation.
    Can anyone help me?
    Thanks in advance.
    Nelson Freitas

    Sorry, but I didn't quite understand the answer. Here's my example, a real one :)
    select     "SGP_DIS_ENT_ANO"."SCE_ID" as " ",
         "SGP_ANO_ESC"."SAE_ANO" as "Ano",
         "SGP_CUR"."SCU_DES" as "Curso",
         "SGP_DIS"."SDE_DES" as "Disciplina"
    from     "SGP_ANO_ESC" "SGP_ANO_ESC",
         "SGP_EST_ANO" "SGP_EST_ANO",
         "SGP_CUR" "SGP_CUR",
         "SGP_DIS" "SGP_DIS",
         "SGP_DIS_CUR" "SGP_DIS_CUR",
         "SGP_DIS_ENT_ANO" "SGP_DIS_ENT_ANO"
    where "SGP_DIS_ENT_ANO"."SDC_ID"="SGP_DIS_CUR"."SDC_ID"
    and     "SGP_DIS_CUR"."SDE_ID"="SGP_DIS"."SDE_ID"
    and     "SGP_DIS_CUR"."SCU_ID"="SGP_CUR"."SCU_ID"
    and     "SGP_DIS_ENT_ANO"."SEA_ID"="SGP_EST_ANO"."SEA_ID"
    and     "SGP_EST_ANO"."SAE_ID"="SGP_ANO_ESC"."SAE_ID"
    and "SGP_DIS_ENT_ANO"."SEN_ID" = :P19_SEN_ID
    Could you help me with it?
    Thanks

  • How to get the last row

    I have 10 rows in my table and I have to retrive last row using rownum.
    For this I use
    SELECT * from <table_name>
    where rownum<=10
    minus
    SELECT * from <table_name>
    where rownum<=9
    The result is no rows selected
    In the same case if I use
    SELECT rownum from <table_name>
    Where rownum <= 10
    minus
    SELECT rownum from <table_name>
    where rownum <=9
    The result is 10
    Why this happend.
    If the result is 10, then why the row whose rowid is 10 is not retrived

    All
    Please bear in mind that ROWNUM is an attribute of the query NOT the table. The last row returned by an unORDERed SELECT statement may be the most recently inserted row but is not guaranteed to be so.
    The only way of assuring yourself of returning the most recent row is either to timestamp all your tables with a date_created column or to use a primary key with an ascending value.
    rgds, APC

  • I need help to find the serial number for Photoshop Elements 11

    Hi! I need help to find the serial number for Photoshop Elements 11 I downloaded last year on Apple Application Store.. I have been using photoshop on mac for over a year and now need the serial number to be able to use it on macbook. I looked up Adobe's website for help but found none and noone to ask for support.. Any ideas how I can get the serial number using the App Sore bill I have?

    Please post Photoshop Elements related queries over at
    http://forums.adobe.com/community/photoshop_elements

Maybe you are looking for

  • Text value not aligned with text caption

    Hello, In my text fields, the text value is always slightly raised from the text caption. Is there a way to get them to align? Thanks, Gail

  • Photoshop CC Extensions menu is not selectable

    Photoshop CC Extensions menu is greyed out. I cannot select event that menu. The extensions installed successfully in Extension Manager CC, no errors. I even tried uninstalling and trying just 1... no dice. I've reinstalled Extension Manager CC witho

  • File content conversion - Receiver config

    Dear Experts , I am transferring data from an Idoc to a target structure ( flat file ) using file content conversion . But the problem is regarding the sequential order of writing the data . >E1EDL24 ( parent ) [  IDoc  ]     xxxxx     yyyyy    zzzzz

  • Colors changing when preview finishes rendering?

    I have been struggling to wrap my head around why Lightroom 1.4 changes the color (mostly vivid red orange -> pale yellowish) once the high resolution preview finishes rendering. Today I photographed a *very* orange butterfly, and it looks just right

  • Alternate solution for Field Exit

    Hi All,   Is there any other way to get the functionality of Field Exit?   According to my requirement, I have to populate some values in a table control based on the value entered in a field.   Please tell me a solution for this. Thanks, Nandhu.