mysqlmysql-error-1055

How to resolve SELECT list is not in GROUP BY clause and contains nonaggregated?


I am getting an error with MYSQL 5.7 on this request. How to resolve this error ?

#1055 - Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.c.customers_group_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

select  SQL_CALC_FOUND_ROWS  c.customers_firstname, 
                             c.customers_lastname, 
                             c.customers_group_id,
                             sum(op.products_quantity * op.final_price) as ordersum 
from customers c,
     orders_products op,
     orders o
where c.customers_id = o.customers_id 
and o.orders_id = op.orders_id 
group by c.customers_firstname, 
         c.customers_lastname 
order by ordersum DESC

Solution

  • include c.customers_group_id also in the group by clause