Description:
Output:
=====
mysql> create table t1(c1 int, c2 int);
insert into t1 values(1,1),(2,0),(Query OK, 0 rows affected (0.01 sec)
mysql> insert into t1 values(1,1),(2,0),(1,3);
select c1, c2 fQuery OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select c1, c2 from t1;
+------+------+
| c1 | c2 |
+------+------+
| 1 | 1 |
| 2 | 0 |
| 1 | 3 |
+------+------+
3 rows in set (0.00 sec)
mysql> select 1 as c3, c1 as c3, c2 as c3 from t1 group by c3;
+----+------+------+
| c3 | c3 | c3 |
+----+------+------+
| 1 | 1 | 1 |
+----+------+------+
1 row in set (0.00 sec)
mysql> select c1 as c3, c2 as c3, 1 as c3 from t1 group by c3;
ERROR 1052 (23000): Column 'c3' in group statement is ambiguous
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.8-rc |
+-----------+
1 row in set (0.00 sec)
Problem:
=====
Since the last two queries differ only in sequence of the same expressions, they are expected to have same result.
How to repeat:
drop table if exists t1;
create table t1(c1 int, c2 int);
insert into t1 values(1,1),(2,0),(1,3);
select c1, c2 from t1;
select 1 as c3, c1 as c3, c2 as c3 from t1 group by c3;
select c1 as c3, c2 as c3, 1 as c3 from t1 group by c3;
Suggested fix:
The last two queries have same result.