environment
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.16 |
+-----------+
Execute query statement
mysql> select * from my_student;
+----+--------+----------+------+--------+
| id | name | class_id | age | gender |
+----+--------+----------+------+--------+
| 1 | 刘备 | 1 | 18 | 2 |
| 2 | 李四 | 1 | 19 | 1 |
| 3 | 王五 | 2 | 20 | 2 |
| 4 | 张飞 | 2 | 21 | 1 |
| 5 | 关羽 | 1 | 22 | 2 |
| 6 | 曹操 | 1 | 20 | NULL |
+----+--------+----------+------+--------+
6 rows in set (0.00 sec)
-- Requirement: After sorting by age, take out the oldest students in each class
select * from (
select * from my_student order by age desc
) as t group by t.class_id;
report errors
ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause
and contains nonaggregated column 't.id'
which is not functionally dependent on columns in GROUP BY clause;
this is incompatible with sql_mode=only_full_group_by
reason:
MySQL 5.7.5 and above function dependency detection function
Solution:
-- View current configuration items
select @@global.sql_mode
-- remove ONLY_FULL_GROUP_BY
set @@global.sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
After setting, if it does not take effect, you can exit and log in again
Read More:
- MYSQL gruop by Error: this is incompatible with sql_mode=only_full_group_by
- [Solved] MYSQL 5.7 gruop by eRROR: this is incompatible with sql_mode=only_full_group_by
- [Solved] MYSQL Start Project Error: this is incompatible with sql_mode=only_full_group_by
- How to Solve MySQL version 5.7+ Group by group error
- [Solved] MySQL Error: “Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre”
- [MySQL] The principle of group by aggregation function and the reason for aggregation limitation SELECT list is not in GROUP BY clause and contains nonaggregated column
- SQL Server Group sort de duplication row_ number() over ( PARTITION BY t1.col_ 2 ORDER BY 1 )
- [Solved] ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregate
- [Solved] Sequelize DatabaseError: ER_WRONG_FIELD_WITH_GROUP: Expression #2 of SELECT list is not in GROUP
- java.sql.SQLException: Disk full (/tmp/#sql_1eaa2_60.MAI); waiting for someone to free some space
- MySQL 8.0.12 runs SQL error #1055 [How to Solve]
- Mysql :error 1111. Invalid use of group function
- [Two Methods] Ora-00904: invalid group by error identifier
- MySQL 8.0 error 1114 (HY000): the table’sbtest1’is full (Fixed)
- postgresql-Database query problem-ERROR: column “t.domainid“ must appear in the GROUP BY clause or be used in an a
- [Linux Docker Mirror] MYSQL Run sql Script Error: Failed to open file ‘/home/mydatabase.sql‘, error: 2
- [Solved] Mysql Close safe-updates Mode Error: Error Code: 1175
- MySQL Build table error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL ser
- MySQL OrderBy Error: Expression #1 of ORDER BY
- [Solved] Caused by: java.sql.SQLException: Access denied for user ‘root‘@‘hadoop102‘ (using password: YES)