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

Mix of aggregate window functions and GROUP BY produces confusing results

    XMLWordPrintable

    Details

      Description

      Semantics of the query below is vague at best, I can't even say what the expected result should be; if the standard does not require such queries to be supported, maybe it would be better to disable them altogether than invent some rules for them.

      drop table if exists empsalary;
      create table empsalary (depname varchar(32), empno smallint primary key, salary int);
      insert into empsalary values  ('develop',1,5000),('develop',2,4000),('sales',3,'6000'),('sales',4,5000);
      

      SELECT depname, empno, salary, avg(salary) OVER (PARTITION BY depname) FROM empsalary group by depname;
      +---------+-------+--------+-----------------------------------------+
      | depname | empno | salary | avg(salary) OVER (PARTITION BY depname) |
      +---------+-------+--------+-----------------------------------------+
      | develop |     1 |   5000 |                               5000.0000 |
      | sales   |     3 |   6000 |                               6000.0000 |
      +---------+-------+--------+-----------------------------------------+
      2 rows in set (0.00 sec)
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              cvicentiu Vicențiu Ciorbaru
              Reporter:
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.