组查询不支持mysql 8;

组查询不支持mysql 8;,mysql,database,group-by,Mysql,Database,Group By,下面的查询在旧版本的MySQL中运行良好 mysql> SELECT business_name, city, -> SUM(lot_count) as lot_count, -> SUM(lot_sold) as lot_sold FROM table_1 GROUP BY business_id, business_location_id; 输出 +--------+------+-------+------------------+-----------

下面的查询在旧版本的MySQL中运行良好

mysql> SELECT business_name, city,
    -> SUM(lot_count) as lot_count,
    -> SUM(lot_sold) as lot_sold FROM table_1 GROUP BY business_id, business_location_id;
输出

+--------+------+-------+------------------+-------------+-------
| business_name            | city      | lot_count | lot_sold  
----------+--------------------------+-----------+---------------+
| test_business_1          | Amsterdam |         4 |       100 
| test_business_2          | Macon     |         10|       30
+--------+------+-------+------------------+-------------+--------
此查询在MySQL 8中不起作用

在MySQL 8中使用上述查询输出

ERROR 1055 (42000):
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'table_1.business_name' which is not functionally dependent on columns in GROUP BY clause;
this is incompatible with sql_mode=only_full_group_by
下面是表中的数据

从表1中选择*

+--------+------+-------+------------------+-------------+--------------------------+-----------+---------------+
| id     |  business_id | business_location_id | business_name            | city      | lot_count | lot_sold  
+--------+------+-------+------------------+-------------+--------------------------+-----------+---------------+
| 263862 |          151 |         176          | test_business_1            | Amsterdam |         1 |       25 
| 263859 |          151 |         176          | test_business_1            | Amsterdam |         1 |       25 
| 263860 |          151 |         176          | test_business_1            | Amsterdam |         1 |       25 
| 263861 |          151 |         176          | test_business_1            | Amsterdam |         1 |       25 
| 263863 |          181 |         221          | test_business_2            | Macon     |         2 |       10 
| 263864 |          181 |         221          | test_business_2            | Macon     |         2 |       10 
| 263866 |          181 |         221          | test_business_2            | Macon     |         6 |       10 
+--------+------+-------+------------------+-------------+--------------------------+-----------+---------------+

试试这个

mysql>选择企业名称、城市、,
->总计(批次计数)为批次计数,

->按业务id、业务位置id、批次计数、批次销售从表1组中销售的批次的总和(已销售批次)

这是否回答了您的问题。请阅读官方文档,正确使用
groupby
。给出与我们通过
Select*从表1中获得的结果相同的结果