[MDEV-10860] Mix of aggregate window functions and GROUP BY produces confusing results Created: 2016-09-21  Updated: 2022-12-15

Status: Confirmed
Project: MariaDB Server
Component/s: Optimizer - Window functions
Affects Version/s: 10.2
Fix Version/s: 10.2

Type: Bug Priority: Trivial
Reporter: Elena Stepanova Assignee: Vicențiu Ciorbaru
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-9896 Testing for window functions Open

 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)


Generated at Thu Feb 08 07:45:29 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.