DataGrid - Query´s Last Row as Footer

Hi!
I have a query like:
SELECT [User], 'Qtd' = Count(DISTINCT [OrderId])
FROM [Jobs]
GROUP BY [User]
UNION
SELECT 'Total', 'Qtd' = Count(DISTINCT [OrderId])
FROM [Jobs];
And I´m displaying this query result in a DataGrid object in an ASPX page.
I´d like to set the last row of the query as a footer with a specific formatting. How do I set the last row of my query as a footer record at the DataGrid?
Thanks,
Molina.

Hello,
Please ask your question over in the ASPNET forum
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

Similar Messages

  • Cfloop query and last row

    Hello everyone,
    I was trying looping over a query which has to be executed
    only when the last row of a previous loop has been reached. The
    question is: I have nested loops, I am able to print the values
    based on two loops:
    for example: <cfloop query="advisor">
    <cfloop students>
    </cfloop>
    </cfloop>
    I am able to get student values for a particular advisor and
    print the values for different advisor and students. I am trying to
    include another loop like grades within advisor loop which should
    be executed at the end of students list for that particular
    advisor. What I am doingg right now is displaying the values in a
    table format.
    <table>
    <tr>Advisor</tr>
    <tr>Student1<tr>
    <tr>Student2</tr>
    <tr>Grades</tr>
    How is possible to know when I would reach the end of the
    student loop for an advisor and then loop the grades for the same
    advisor before proceeding to another advisor?
    Any suggestions would be great.
    Thanks.

    The group attribute of cfoutput would be a lot more
    efficient. Useage is described in the cfml reference manual. If you
    don't have one, the internet does.
    It would also be more efficient to get all your data with a
    single query.

  • How to get the last row in a resultset or query

    Hi All
    Say If I have a complex query which returns a resultset say 15 rows. Now I want to limit the output showing only the last row.
    How can we do this

    Keep in mind Oracle does not keep "row" order as such. Unlike a graphical type db like Access, Oracle will not always give you back the results in order.
    Even if you were to use a sequence, your query is never guaranteed to give back the results in the order you are expecting. You must then give an order by statement to all queries expecting the order.
    Your definition of last row too is vague - if it is in fact the greatest amount, use the inline view suggestion. If you simply want to see the last inserted row, consider adding a last_update_date column inserting the sysdate (by a trigger perhaps). This would then allow you to see the last inserted row.
    Enjoy!

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

  • 3.5 Query Designer has 'row' in the footer of results but 7.0 has 'page'

    3.5 Query Designer has 'row' in the footer of results but 7.0 has 'page' is there a way to change 7.0 to have 'row' instead of 'page'? We would prefer to see how many rows of data we have. I didn't know if this was a parameter they may be able to be changed.
    Thanks,
    Diane

    I donot think there is way to display Row instead of Page.
    Also in 7.0. It is based on cells.

  • Datagrid last row flickering problem.

    Hi,
        I used flex 3.5 datagrid. It is a complex datagrid with lot of itemrenderers and itemeditors.when my datagrid has vertical scroll and when i scroll datagrid, last row keep on flickering.
         any idea or solution for this problem?   

    my grid contains 6 columns. Among 6, some of the column texts are  visible some of them hided.
    it is only happens to last row of the Datagrid.
    This is happened when i scroll my datagrid vertically.

  • Lock datagrid last row with agregates (don't know what to do next :( )

    Hi,
    I have been googling for 2 hours and have been reading some forum posts, etc... but can't get this thing working. It seems an important flaw in datagrid, because I'm sure lota peopple needs this, but I've not found a good solution.
    What I need to do is add a row of agregates to a datagrid that contains flat data (it must be last one, and locked, I mean, must not scroll). I have been reading about this:
    http://blogs.adobe.com/aharui/2008/03/flex_3_datagrid_footers.html
    But this makes the row separated from the grid, I mean, It is not really a datagrid row. Other problems arise using this implementation like, impossibility to keep last row aligned with datagrid columns when scrolling (I need to scroll because I have lota columns), etc...
    So, could anybody please help here to accomplish this? I think it is a pretty common task and it is a bit dissapointing it can't be done easily with flex.
    Thanks in advance,
    Aron.

    I haven't seen this done.
    You can add a summary row fairly easily using the Advanced Data Grid:
    http://livedocs.adobe.com/flex/3/html/help.html?content=advdatagrid_10.html

  • Query result area on the first row instead of last row

    Hi BI experts,
    I want to display the result of  the BI query at the first row instead of last row.Could somebody help me how to accomplish this.
    I tried with the layout->move result area but could not be possible.
    I need your kind suggetion.
    Thanks.

    hi jyuoti,
    Further, open your query in query designer, look at the query property,  under the tab "rows/columns"
    change the result position of rows to "Below", you can see the preview there itself.
    This should solve your problem.
    Best Regards,
    *Assign points if you find the answer useful.

  • 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

  • How to write a query to get the total as a last row

    Hi,
    I need to get something like this ....
    |TEAM LEADER| TEAM | OCT TRN | EMPS| YTD% |
    |_____________|__________|__________|______|_______|
    | JOHN | JD Team | 12 | 12 | 100 |
    |_____________|__________|__________|______|_______|
    | Total |      | 12 | 12 | 100 |
    |_____________|__________|__________|______|_______|
    I have to get the last row as total adding the number columns ...
    Thanks in advance ...

    Take a look at the GROUP BY ROLLUP feature:
    create table t1
    (team_name      varchar2(30)
    ,wins           number
    ,losses         number
    insert into t1 values ('Hornets',3,1);
    insert into t1 values ('Panthers',4,0);
    insert into t1 values ('Wolves',2,2);
    insert into t1 values ('Badgers',0,4);
    insert into t1 values ('Hornets',1,3);
    commit;
    select decode(team_name,
                 NULL,'TOTAL',
                 team_name) team_name, sum(wins), sum(losses)
    from   t1
    group by rollup(team_name);
    TEAM_NAME                                 SUM(WINS)          SUM(LOSSES)
    Badgers                                           0                    4
    Hornets                                           4                    4
    Panthers                                          4                    0
    Wolves                                            2                    2
    TOTAL                                            10                   10

  • 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

  • Trying to get the last row from a resultset

    Hi,
    I'm trying to do a query to postgreSQL and have it return the last updated value, (last row).
    My prepared statement is returning the correct results, but i'm having a problem getting the latest value.
    I'm using a comboBox to drive a textfield, to load the last entered values in depending on which item in the comboBox is selected.
    I've tried a variety of things and most seem to return the first row, not showing the updated values.
    Or, if it does work, it takes to long to load, and i get an error.
    here is the working code;
    Object m = machCBX.getSelectedItem():
    try { PreparedStatment last = conn.prepareStatement("SELECT part, count FROM production WHERE machine = ?",
    ResultSet.TYPE_SCROLL_INSENSITIVE,  //tried both INSENSITIVE and SENSITIVE
    ResultSet.CONCUR_READ_ONLY);
    last.setString(1, String.valueOf(m));
    rs. = last.executeQuery();
    if(rs.isAfterLast) == false ) {
    rs.afterLast();
    while(rs.previous()) {
    String p = rs.getString("part");
    int c = rs.getInt("count");
    partJTX.setText(p);
    countJTX.setText(c);
    }this grabs values, but they are not the last entered values.
    Now if i try to use rs.last() it returns the value i'm looking for but takes to long, and i get:
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space I also know using ra.last() isn't the best way to go.
    I'm just wondering if there is another way other than getting into vectors and row count? or am i better off to go with the later?
    thanks
    -PD

    OK, you've got a major misunderstanding...
    The relational database model is built on the storage of sets - UNORDERED sets. In other words, when you hand a database a SELECT statement without an ORDER BY clause, the database is free to return the results in any order.
    Now it so happens that most databases will happen to return data retrieved by an unordered SELECT, at least for a while, in the same order that it was inserted, especially if no UPDATE or DELETE activity has occured, and no database maintenance has occured. However, eventually most tables have some operation that creates a "space" in the underlying storage, or causes a row to expand and have to be moved or extended, or something. Then the database will start returning unordered results in a different order. If you (or other people) never ever ever UPDATE or DELETE a table, then on some databases the data might well come out in insertion order for a very very long time; given human nature and the way projects tend to work, relying on that is a sucker's bet, IMHO.
    In other words, if you want the "most recent" something, you need to store a timestamp with your data. (With some databases, you might be able to take advantage of some non-standard feature to get "last updates" or "row change timestamps", but I know of no such for Postgres.
    While this won't solve your major problem, above, your issue with rs.last is probably occuring because Postgres by default will prefetch your entire ResultSet. Use Statement.setFetchSize() to change that (PreparedStatement inherits the method, of course).

  • 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

  • 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

  • Import the last row written in a database

    Hello!
    I want know what i have to do to import the last row written in a table from a MySQL database.
    I'm using labview database toolkit.
    Thank you in advanced.
    Larson

    Hi Larson
    I total agree that my first suggestion isn't what you want but I wanted to put the idea across that you can retrieve records from table in the order they were written using a simple SQL command.
    When dealing with databases I always design my queries using Design View in MS Access. Once you have the query designed you can then convert the query you have just designed in Design View to SQL by changing to SQL View.
    So this example SQL statement would return the MAX Timestamp.
    SELECT Max(tblTimeStampTest.Timestamp) AS MaxOfTimestamp
    FROM tblTimeStampTest;
    Say the timestamp was 12/14/2005 8:18:33
    SELECT tblTimeStampTest.*
    FROM tblTimeStampTest
    WHERE (((tblTimeStampTest.Timestamp)=#12/14/2005 8:18:33#));
    This will return your last record as long at the timestamps are unique and records are written in timestamp order. You can then use Build Text Express VI or Format into String to build your SQL strings that have variables like the timestamp above.
    I have no experience with mySQL but I would assume MS Access could interface to it somehow either through ODBC or MS Access Projects so that can build you SQL commands.
    David

Maybe you are looking for

  • QaaWS not returning data in Xcelsius

    My dashboard Data is not displayed in Xcelsius or InfoView and have encountered the error as below: All of your system's 0 Concurrent Access Licenses are in use at this time or your system's license key has expired. Try again later or contact your ad

  • How do I set up the email settings

    How do I set up the email settings, so the Phone will catch all my junk mail and put it in the junk mail folder? I have a yahoo email account if it matters.

  • Cannot load XML file in Screen Painter in SAPB1

    Hi All, i am creating an xml file of existing purchase order through the following code Public Sub getxml(ByVal FormUID As String)         Dim f As SAPbouiCOM.Form         f = sbo_application.Forms.Item(FormUID)         Dim oXmlDoc As Xml.XmlDocument

  • BTYahoo! Email IMAP - Problem saving messages in S...

    I have been using BTYahoo! email with IMAP for several years now. One problem that I never used to have has become more and more regular over the last six months or so. It is now at the point where I get this problem 95% of the time when sending mess

  • Routine help - urgent

    Hi guys, Need help for routine code, i have rquirement currency translation based on currency type  In the cube we having the Amount Key Figure in USD. i want to convert these values based on currency type or company code . ..GBP,JPY,INR,KRW..etc. ca