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

Wrong result from query, using window function and GROUP BY .. WITH ROLLUP

    XMLWordPrintable

Details

    Description

      CREATE TABLE t1 (i int);
      INSERT INTO t1 VALUES (1), (1), (2), (2), (3), (3);
       
      SELECT i, SUM(i) OVER () FROM t1 GROUP BY i ;
      SELECT i, SUM(i) OVER () FROM t1 GROUP BY i WITH ROLLUP;
      

      MariaDB [test]> SELECT i, SUM(i) OVER () FROM t1 GROUP BY i;
      +------+----------------+
      | i    | SUM(i) OVER () |
      +------+----------------+
      |    1 |              6 |
      |    2 |              6 |
      |    3 |              6 |
      +------+----------------+
      3 rows in set (0.005 sec)
       
      MariaDB [test]> SELECT i, SUM(i) OVER () FROM t1 GROUP BY i WITH ROLLUP;
      +------+----------------+
      | i    | SUM(i) OVER () |
      +------+----------------+
      |    1 |              9 |
      |    2 |              9 |
      |    3 |              9 |
      | NULL |              9 |
      +------+----------------+
      4 rows in set (0.003 sec)
      
      

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            alice Alice Sherepa
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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