Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'madteam_usuaris.usuarisEntradas.fecha' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by select FROM_UNIXTIME(fecha,'%Y'),FROM_UNIXTIME(fecha,'%m') from madteam_usuaris.usuarisEntradas where public='si' and idUser='690' and tipo='relat' group by FROM_UNIXTIME(fecha,'%Y'),FROM_UNIXTIME(fecha,'%m') ORDER BY fecha DESC