Documenting this error and solution here in case it could help anyone.
We have a MYSQL 8 database on Amazon RDS.
The below group by used to work just fine on Mysql 5.7 but it started giving
1022 Can't write; duplicate key in table '/rdsdbdata/tmp/#sqlf80_1656bc_0'
error once we upgraded to Mysql 8.
GROUP BY DATE_FORMAT(CONCAT(YEAR(performance_stats_date),'-',
MONTH(performance_stats_date),'-',DAY(performance_stats_date)),
'%Y-%m-%d')
Best Answer
That's the wrong way to use
DATE_FORMAT
. It is given aDATE
orDATETIME
and a string providing the 'formatting'. Example:In your case, it would be something like
But this is even simpler:
For further discussion, please provide