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

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

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

            alice Alice Sherepa created issue -
            alice Alice Sherepa made changes -
            Field Original Value New Value
            Assignee Varun Gupta [ varun ]
            alice Alice Sherepa made changes -
            Status Open [ 1 ] Confirmed [ 10101 ]
            varun Varun Gupta (Inactive) made changes -
            varun Varun Gupta (Inactive) made changes -
            Fix Version/s N/A [ 14700 ]
            Fix Version/s 10.2 [ 14601 ]
            Fix Version/s 10.3 [ 22126 ]
            Fix Version/s 10.4 [ 22408 ]
            Resolution Duplicate [ 3 ]
            Status Confirmed [ 10101 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 93573 ] MariaDB v4 [ 156001 ]

            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.