goInception icon indicating copy to clipboard operation
goInception copied to clipboard

创建视图时报 SELECT list is not in GROUP BY clause and contains nonaggregated column

Open ZhuhongLee opened this issue 1 year ago • 3 comments

描述 创建视图 create or replace view test_dba as SELECT name,round(sum(score),2) as score from test group by name ; 检测时报错 Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'ROUND(SUM(score), 2)' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by.

重现 create table test (id int auto_increment PRIMARY key ,name VARCHAR(10) , score DECIMAL(5,3)) ;

insert into test(name,score) values('张三',66.789); insert into test(name,score) values('张三',77.789); insert into test(name,score) values('张三',88.789); insert into test(name,score) values('李四',99.789); insert into test(name,score) values('李四',90.789);

create or replace view test_dba as SELECT name,round(sum(score),2) as score from test group by name ; 点击检测时报错

环境

  • 数据库: [阿里云 RDS MySQL]
  • 版本: [例如 8.0.28]

参数 inception 的sql_mode ="" ,跟随目标实例

ZhuhongLee avatar Jan 16 '24 03:01 ZhuhongLee

可以看下我fork的分支https://github.com/zmix999/goInception

zmix999 avatar Mar 28 '25 02:03 zmix999

可以看下我fork的分支https://github.com/zmix999/goInception

可以检测通过,感谢

ZhuhongLee avatar Apr 22 '25 09:04 ZhuhongLee

可以看下我fork的分支https://github.com/zmix999/goInception

请问这是啥问题,怎么解决的呢

LiuHuAshen avatar Jul 04 '25 07:07 LiuHuAshen