Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Not a Bug
-
10.0(EOL), 10.1(EOL)
-
None
Description
This script:
DROP TABLE IF EXISTS t1,t2;
|
CREATE TABLE t1 (c1 INT DEFAULT NULL);
|
INSERT INTO t1 (c1) VALUES (1),(2),(3),(4);
|
CREATE TABLE t2
|
SELECT
|
NULLIF(AVG(c1),0e0) AS c1,
|
IF(AVG(c1)=0e0,NULL,AVG(c1)) AS c2,
|
CASE WHEN AVG(c1)=0e0 THEN 0e0 ELSE AVG(c1) END AS c3
|
FROM t1;
|
SHOW CREATE TABLE t2;
|
returns
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| t2 | CREATE TABLE `t2` (
|
`c1` decimal(14,4) DEFAULT NULL,
|
`c2` decimal(14,4) DEFAULT NULL,
|
`c3` double DEFAULT NULL
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
|
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
All three columns should be of the same data type.