Skip to content

[Bug]: Cannot sort column DESC by click when it is named COUNT(*) #20509

Open

Description

@M393

Describe the bug

Changing sort direction by click to DESC for a column named COUNT(*) does not work .

How to Reproduce

  1. Execute this sql
SELECT *
FROM (
    SELECT type, COUNT(*)
    FROM (SELECT 1 AS type UNION ALL SELECT 2 UNION ALL SELECT 2) AS d
    GROUP BY type
) AS c
  1. Then click the COUNT(*) column header to sort it ASC
  2. Click again to sort it DESC
  3. Sort order didn't change.

Expected behavior

First click should sort ASC, second click should sort DESC.

Database version

MariaDB 11.4

phpMyAdmin version

QA_5_2

Additional context

It works if the column gets an alias:

SELECT *
FROM (
    SELECT type, COUNT(*) AS cnt
    FROM (SELECT 1 AS type UNION ALL SELECT 2 UNION ALL SELECT 2) AS d
    GROUP BY type
) AS c

or if the COUNT(*) function is used directly:

SELECT type, COUNT(*)
FROM (SELECT 1 AS type UNION ALL SELECT 2 UNION ALL SELECT 2) AS d
GROUP BY type

Activity

  1. added
    BugA problem or regression with an existing feature
    on Oct 2, 2026
  2. liviuconcioiu commented on Oct 2, 2026

    @liviuconcioiu
    Contributor

    Not sure if related #18075.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA problem or regression with an existing feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions