SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Rollup

  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    London
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rollup

    Code:
     SELECT SUM(a*b) as total FROM tab_1 GROUP BY a WITH ROLLUP
    I've run this simple query in the terminal and it's ok

    Does anyone know how to echo out the last row generated by the modifier GROUP BY....WITH ROLLUP ?

    Like I just want the total and not the figures which make it up.

    (There may be disagreement but I think this query is OK in the Mysql forum.)

    Marmot

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    700
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Just remove the group by clause

    Code:
    SELECT SUM(a*b) as total FROM tab_1

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    London
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that does it! thank you!

    PHP Code:
     <?php
    $dbcnx
    =mysql_connect 'localhost','root','blah' );
    mysql_select_db sumtext,$dbcnx );
    $sql ="SELECT SUM(a*b) as total FROM tab_1";
    $result mysql_query ($sql);
    $row mysql_fetch_array $result );



    echo (
    $row ['total'] ."<p>");

      
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •