sql - MySQL seems to have a bug with distinct, avg, and group-by -



sql - MySQL seems to have a bug with distinct, avg, and group-by -

the next query seems behave incorrectly. grouping on single field , average on field distinct avg should homecoming 1 row every distinct average. if avg replaced count illustration query homecoming 2 rows , if distinct removed or replaced query returns 3 rows.

create table x (x real); insert x values (1), (2), (3), (3); select distinct avg(x) x grouping x;

mysql returns:

+--------+ | avg(x) | +--------+ | 1 | +--------+

postgres returns:

avg ----- 1 2 3

below query homecoming output :

avg ----- 1 2 3

query

select avg(x) x grouping x;

here sql fiddle

demo

mysql sql rdbms

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -