# SELECT list is not in GROUP BY clause

**URL:** <https://forum.shopware.com/t/select-list-is-not-in-group-by-clause/65955>\
**Category:** Programming (EN)\
**Created:** [2. April 2020 um 07:45 UTC](https://forum.shopware.com/t/select-list-is-not-in-group-by-clause/65955 "2020-04-02T07:45:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abinjohnedamana](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/abinjohnedamana/32/17378_2.png) [@abinjohnedamana](https://forum.shopware.com/u/abinjohnedamana)\
**Post date:** [2. April 2020 um 07:45 UTC](https://forum.shopware.com/t/select-list-is-not-in-group-by-clause/65955/1 "2020-04-02T07:45:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![abinjohnedamana](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/abinjohnedamana/32/17378_2.png) [@abinjohnedamana](https://forum.shopware.com/u/abinjohnedamana)\
**Post date:** [2. April 2020 um 07:46 UTC](https://forum.shopware.com/t/select-list-is-not-in-group-by-clause/65955/2 "2020-04-02T07:46:06Z")

</div>

> <https://stackoverflow.com/questions/41887460/select-list-is-not-in-group-by-clause-and-contains-nonaggregated-column-inc>

SET GLOBAL sql\_mode=(SELECT REPLACE(@@sql\_mode,‚ONLY\_FULL\_GROUP\_BY‘,’’));

---

<div class="post-metadata">

**Author:** ![Krispin](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/krispin/32/12849_2.png) [@Krispin](https://forum.shopware.com/u/Krispin)\
**Post date:** [2. April 2020 um 08:56 UTC](https://forum.shopware.com/t/select-list-is-not-in-group-by-clause/65955/3 "2020-04-02T08:56:22Z")

</div>

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
