Mysql error 1140 - in aggregated query without group by, express number # 1 of success list contains nonaGgreg

tags: Simple record  mysql  sql  database

Execute SQL query statement:

SELECT
    IFNULL(
        c.card_type_name,
        '**name'
    ) AS card_type_name,
    IFNULL(sum(a.money), 0) AS frje
FROM
    agent_profit a
LEFT JOIN card_index b ON a.card_no = b.card_no
LEFT JOIN card_type c ON b.card_type = c.card_type
WHERE
    1 = 1
AND a.cre_time LIKE '2020-09%'
AND c.card_type = 'card_**lt'

Wrong

[Err] 1140 - In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'cust_cx.c.card_type_name'; this is incompatible with sql_mode=only_full_group_by

[Err] 1140 - In the aggregate query without group BY, the expression 1 of the selection list includes non-polymer columns "Cust_cx.c.card_type_name"; this is not compatible with SQL "Mode = Only" full "group" BY

In the aggregate query of the Group By clause, the first expression in the SELECT list contains non-polymer columns ** (change to the party function formation can be performed normally); when SQL_MODE is ONLY_FULL_GROUP_BY, it is not possible This happens.
That is, when mysql's SQL_MODE is ONLY_FULL_GROUP_BY, if the GROUP BY is not used and the aggregation function is displayed later, then all of the SELECT should be a gathering function, otherwise it will report an error.

solve:

Query mysql installation file: Whereis mysql
Edit the /etc/my.cnf file, add the following parameters,

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

 

My.cnf file: before modify

[mysqld]
basedir=/**/**/mysql-5.7.25
datadir=/**/**/mysql-5.7.25/data
socket=/tmp/mysql.sock
port=3306



# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/**/**/mysql-5.7.25/data/mysqld.log
pid-file=/**/**/mysql-5.7.25//data/mysqld.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

After modification:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
 basedir = /**/**/mysql
 datadir = /**/**/data
 port = 3306
 server_id = 100
 socket = /tmp/mysql.sock

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

Restart mysql

service mysqld restart

Intelligent Recommendation

MySQL:ERROR 1140 (42000): In aggregated query without GROUP BY, expression #1 of SELECT list c

This wrong Chinese translation: In the aggregate query without using the Group By clause, the first expression in the SELECT list contains non-polymeric column 'school.student.s_id'; this is not possi...

Mysql error: In aggregated query without GROUP BY

【phenomenon】 【solve】...

MySQL error in aggregated query without group by

Execute a statement: select de.dept_no, count(s.salary) from salaries s left join dept_emp de on s.emp_no = de.emp_no; Complete error message: In aggregated query without GROUP BY, expression #1 of SE...

Given: In aggregated query without GROUP BY, expression # 1 of SELECT list contains nonaggregated column

sql statement error contents: Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: In aggregated query without GROUP BY, expression #1 of SELECT list contains non...

MySQL error: in aggregated query without group by, incompatible with sql_mode = only_full_group_by

Scenario: The same product, different models, there are different prices, such as 1 mobile phone has 128G, 2,256g, 2500 yuan, but the product display page, the price shows 2,000 yuan, if it is a produ...

More Recommendation

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: In aggregated query without GROUP BY, error

  The above error is due to the sql_mode setting. I use mysql8. Reset the sql_mode and remove ONLY_FULL-GROUP_BY: This is only a temporary solution. In fact, the real solution should be to see th...

What is the error in aggregated query without group by?

Table used herein: group by SQL often appears below First explain AggRegate is a kind of function in SQL, which is calledPolymerization function, The following is a polymeric function AVG () - Return ...

MySQL uses group_concat in aggregated query without group by

1 Reason: Use group_concat in SQL to combine, if you are other group by reason, please find other solutions Online explanation: After mysql5.7.5, the default opened online, so some SQL could not be ex...

MySQL8 solves In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated...

MySQL8 solves In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated... 1. Reason for error 2. Solution 2.1 Temporarily 2.2 Long-term 1. Reason for error MySQL8 is o...

In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'en

The reason for this is that the mysql database version is higher than the jar package version you imported. After MySQL 5.7.5, ONLY_FULL_GROUP_BY is turned on by default, so some of the previous SQL c...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top