I have a problem with the query below in MySQL 5.7, but in MySQL 5.6 it is working well.
This message appears every time:
1055 - Expression #6 of SELECT list is not in GROUP BY clause and contains nonaggregated column
'electricity_databases.electricity_invoices.date_inserted' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
SQL code:
SELECT
homes.id,
homes.homeName,
homes.city,
homes.date_registered,
ROUND(SUM(electricity_invoices.total), 2) AS TotalPrice,
DATEDIFF(NOW(), electricity_invoices.date_inserted) AS last_insert_in_days,
MAX(electricity_invoices.date_inserted) AS last_insert,
COUNT(electricity_invoices.homeID) AS countPaymentTimes,
MAX(electricity_invoices.currRead) AS currRead,
MAX(electricity_invoices.prevRead) AS prevRead,
ROUND(MAX(electricity_invoices.currRead) - MAX(electricity_invoices.prevRead), 1) AS lastComp,
customer.name
FROM homes
LEFT JOIN electricity_invoices ON
homes.id = electricity_invoices.homeID
LEFT JOIN customer ON
homes.id = customer.homeID
GROUP BY homes.id
ORDER BY homes.id