http://www.hellojava.com/a/54977.html
1055 - Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘qdhr_dwd_test.dwd_user_department.company_id’ which is not >functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
mysql :5.7.31
mysql语句如下:
SELECT
pu.pu_ward_name,
entry_date,
pu.o_code,
pu.pu_ward_name,
pu.pu_lga_name,
pu.pu_code,
pu.pu_ward_code,
pu.pu_lga_code,
pu.pu_voters_reg_count,
SUM(total_vote_cast) AS total_vote_cast,
SUM(apc_total_vote) AS apc_total_vote,
SUM(pdp_total_vote) AS pdp_total_vote,
SUM(adp) AS adp, ward_name
FROM
post_election_info r
LEFT JOIN polling_unit pu ON r.ward_name = pu.pu_ward_name
WHERE lga_name = 'BORIPE'
GROUP BY
pu.pu_ward_name
修改:
SELECT
pu.pu_ward_name,
MAX(entry_date) AS entry_date,
MAX(pu.o_code) AS o_code,
MAX(pu.pu_lga_name) AS pu_lga_name,
MAX(pu.pu_code) AS pu_code,
MAX(pu.pu_ward_code) AS pu_ward_code,
MAX(pu.pu_lga_code) AS pu_lga_code,
MAX(pu.pu_voters_reg_count) AS pu_voters_reg_count,
SUM(total_vote_cast) AS total_vote_cast,
SUM(apc_total_vote) AS apc_total_vote,
SUM(pdp_total_vote) AS pdp_total_vote,
SUM(adp) AS adp
FROM
post_election_info r
LEFT JOIN polling_unit pu ON r.ward_name = pu.pu_ward_name
WHERE lga_name = 'BORIPE'
GROUP BY
pu.pu_ward_name
大功告成