Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-30890

HAVING clause causes ORDER BY statement to fail when window function in use

    XMLWordPrintable

Details

    Description

      @@version:
      10.4.27-MariaDB-1:10.4.27+maria~ubu2004

      The following query honors the ORDER BY statement when the HAVING clause is commented out, but ignores the ORDER BY statement when the HAVING clause is not commented out:

      SELECT	cause_id, 
      		COUNT(*) as cause_row_count, 
      		COUNT(*) OVER() as cause_count
      FROM	test_db.test_run_log 
      WHERE   test_run_id = 1
      GROUP BY cause_id
      -- HAVING   COUNT(*) = 5
      ORDER BY cause_id;
      

      NOTE that when window OVER function column is commented out, and the HAVING clause is not commented out, the ordering of rows are as expected.

      Attachments

        Activity

          People

            Unassigned Unassigned
            kevinoh@uw.edu James Kevin O'Halloran
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.