Menu

#619 (2.3.3-rc1) ORDER BY SUM(var) / COUNT(*)

2.3.3-rc1
fixed
1
2013-07-20
2002-10-06
No

When displaying a table, pma gives the option to sort after a certain
column. If a column is 'COUNT(*)' or 'SUM(var)' and you click on it, it
will be sorted ASC but if you click it again it still will be sorted ASC i.e.
it's not possible to let it sort DESC.

Related

Bugs: #4030

Discussion

  • Loïc Chapeaux

    Loïc Chapeaux - 2002-10-07

    Logged In: YES
    user_id=144058

    Hi!

    Can you give a try to the live demo. I remember I've fixed such
    kind of bug but I'm not sure when...

    Loc

     
  • Marc Delisle

    Marc Delisle - 2002-10-07

    Logged In: YES
    user_id=210714

    Bug still there in cvs.

     
  • Robin Johnson

    Robin Johnson - 2002-10-13
    • assigned_to: robbat2 --> nobody
    • labels: 438488 -->
     
  • Alexander M. Turek

    Logged In: YES
    user_id=418833

    I could also reproduce this bug and ran into another one.
    But I'll open a new report for this.

     
  • Marc Delisle

    Marc Delisle - 2002-10-20

    Logged In: YES
    user_id=210714

    The problem is that the brackets of the expression COUNT(*)
    are not escaped before entering the regexp, so in
    display_tbl.lib.php3, section 2.1.2, replace the $is_in_sort
    line with:

    $pattern = str_replace('\\', '\\\\', $fields_meta[$i]->name);
    $pattern = str_replace('(','\(', $pattern);
    $pattern = str_replace(')','\)', $pattern);
    $is_in_sort = eregi('[[:space:]](`?)' . $pattern . '(`?)[
    ,$]',$sql_order);

    Feedback?

     
  • Marc Delisle

    Marc Delisle - 2002-10-20
    • assigned_to: nobody --> lem9
     
  • Marc Delisle

    Marc Delisle - 2002-10-21

    Logged In: YES
    user_id=210714

    Merged.

     
  • Marc Delisle

    Marc Delisle - 2002-10-21
    • priority: 5 --> 1
    • status: open --> open-fixed
     
  • Loïc Chapeaux

    Loïc Chapeaux - 2002-10-22

    Logged In: YES
    user_id=144058

    Hi!

    Well this problem is the same than the one reported in bug
    #605030 (Problems with [] in Tablename) : as soon as a there
    is a special regexp character in the pattern we will face such
    kind of error.

    Maybe we will have to think a bit more about these problems?

    Loc

     
  • Alexander M. Turek

    • status: open-fixed --> closed-fixed
     
  • Alexander Schuch

    Logged In: YES
    user_id=501368

    I tried the statement 'SELECT _MemberID, COUNT(*), SUM(1) FROM
    sites GROUP BY _MemberID'. Ordering by clicking on the 'SUM(1)'
    column header works perfectly but not clicking on 'COUNT(*)'. Clicking
    on it the first time, all rows get sorted by proper 'COUNT(*)' value but there
    is no down arrow next to 'COUNT(*)' indicating that data is sorted after
    that values. Clicking on 'COUNT(*)' header again will still sort ascending.

     
  • Alexander Schuch

    • labels: --> MySQL Parser
    • milestone: 241863 --> 2.3.3-rc1
    • priority: 1 --> 5
    • summary: (2.3.1) ORDER BY SUM(var) --> (2.3.3-rc1) ORDER BY SUM(var) / COUNT(*)
    • status: closed-fixed --> open-fixed
     
  • Alexander Schuch

    Logged In: YES
    user_id=501368

    btw: I'm unable to set 'Resolution' to 'none'... using Opera 6.05. :-/

     
  • Alexander M. Turek

    Logged In: YES
    user_id=418833

    Changing "Resolution" to "None" doesn't work with any
    browser due to an SF bug.

    When sending a SELECT query containing a GROUP BY
    satement, I'm unable to use the sorting function: The column
    head just isn't clickable!

    Server:
    Windows NT 5.2 RC1
    Apache 2.0.43 / IIS 6.0
    PHP 4.4.0-dev
    MySQL 4.0.5-beta

    Client:
    Windows NT 5.1
    MSIE 6.0 SP1 / Opera 7.0 beta 1

     
  • Alexander M. Turek

    • status: open-fixed --> open-accepted
     
  • Alexander M. Turek

    Logged In: YES
    user_id=418833

    ci-dev, I'm a little confused:
    How could you test this, if you have the same problem as me
    (bug #642319)? :o)

     
  • Alexander Schuch

    Logged In: YES
    user_id=501368

    I added another note to my initial note of bug #642319. Using this peace of
    information should allow you to create simple 'GROUP BY' statements
    with a clickable header.

    btw: Where can I get 'PHP 4.4.0-dev'? ;-)

     
  • Alexander M. Turek

    Logged In: YES
    user_id=418833

    Now that bug #642319 is fixed (thanks, Marc) I could
    reproduce the bug.

    btw: the latest PHP CVS snapshots (updated every few
    hours) are available on <http://snaps.php.net>.

     
  • Marc Delisle

    Marc Delisle - 2002-11-23

    Logged In: YES
    user_id=210714

    Please try the new fix I just merged.

     
  • Marc Delisle

    Marc Delisle - 2002-11-26
    • priority: 5 --> 1
     
  • Marc Delisle

    Marc Delisle - 2002-12-02
    • status: open-accepted --> closed-accepted
     
  • Michal Čihař

    Michal Čihař - 2013-06-11
    • Status: closed-accepted --> fixed
     
  • Alexander Schuch

    First of all, sorry that it took me more than 10 years to check back on this.

    However, in 4.0.4.1 it still does not work in all cases. The query "SELECT SUM(field) FROM table GROUP BY field2" can be sorted ASC and DESC on the SUM column using the GUI. But as soon as I escape the argument, sorting will stick to ASC.

    "SELECT SUM(field) FROM table GROUP BY field2" (note the backticks around "field") cannot be sorted DESC on SUM column using the GUI.

    PS: I am perfectly fine to let this bug report rest in peace and to move my issue to a new one. It's up to you.

    Edit: For some reason, I do not find a way to re-open this ticket, so I created a new one, see [bugs:#4030].

     

    Related

    Bugs: #4030


    Last edit: Alexander Schuch 2013-07-20
  • Marc Delisle

    Marc Delisle - 2013-07-20

    Wow, thanks for your feedback. You probably hold the record for pioneer users of phpMyAdmin who reported a bug and are still interested in its outcome.