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

Wrong results from query, using expression with aggregated function and window function

    XMLWordPrintable

Details

    Description

      create table t1(i int);
      insert into t1 values  (1),(2),(3),(4),(5);
       
      select sum(i) over (order by sum(i)) from t1 group by i;
      select sum(i) over (order by sum(i)+1) from t1 group by i;
      

      MariaDB [test]> select sum(i) over (order by sum(i)) from t1 group by i;
      +-------------------------------+
      | sum(i) over (order by sum(i)) |
      +-------------------------------+
      |                             1 |
      |                             3 |
      |                             6 |
      |                            10 |
      |                            15 |
      +-------------------------------+
      5 rows in set (0.002 sec)
       
      MariaDB [test]> select sum(i) over (order by sum(i)+1) from t1 group by i;
      +---------------------------------+
      | sum(i) over (order by sum(i)+1) |
      +---------------------------------+
      |                              15 |
      |                              15 |
      |                              15 |
      |                              15 |
      |                              15 |
      +---------------------------------+
      5 rows in set (0.001 sec)
      
      

      Mysql 8.0.15:

      mysql> select sum(i) over (order by sum(i)) from t1 group by i;
      +-------------------------------+
      | sum(i) over (order by sum(i)) |
      +-------------------------------+
      |                             1 |
      |                             3 |
      |                             6 |
      |                            10 |
      |                            15 |
      +-------------------------------+
      5 rows in set (0.00 sec)
       
      mysql> select sum(i) over (order by sum(i)+1) from t1 group by i;
      +---------------------------------+
      | sum(i) over (order by sum(i)+1) |
      +---------------------------------+
      |                               1 |
      |                               3 |
      |                               6 |
      |                              10 |
      |                              15 |
      +---------------------------------+
      5 rows in set (0.00 sec)
      

      Attachments

        Issue Links

          Activity

            People

              varun Varun Gupta (Inactive)
              alice Alice Sherepa
              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.