SELECT list is not in GROUP BY clause

Hi

When I am trying to execute these query in MySQL

SELECT
order_line_item.product_id,
order_line_item.label,
SUM(order_line_item.quantity) AS totalQuantity
FROM
order_line_item
GROUP BY
order_line_item.product_id
ORDER BY
totalQuantity
DESC

I got the following error

Error in query (1055): Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘shopware6_demo.order_line_item.label’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,‚ONLY_FULL_GROUP_BY‘,’’));

Hi,

you have to add „order_line_item.label“ to the group by list, then it should work.

P.S.: Maybe you could use th DAL for this kind of query.

Best Regards

Krispin