mysq 报错, sql语句在数据库里运行正常, 在内网测试正常,打包放外网的时候就报下面错误
sql语句为:
select t1.day as day , any_value(IFNULL(t2.avgNum,0)) as avgNum, any_value(IFNULL(t2.maxNum,0)) as maxNum
from ( SELECT date_add( date_sub('2021-03-01',interval 1 day), INTERVAL ( cast( help_topic_id AS signed ) + 1 ) day ) day
FROM mysql.help_topic
WHERE help_topic_id <= DATEDIFF('2021-03-03',date_sub('2021-03-01',interval 1 day))) t1
left JOIN
(select ctime, any_value(sum(hourNum)) as avgNum, any_value(MAX(hourNum)) as maxNum from ( select any_value(DATE_FORMAT(create_time,'%Y-%m-%d')) as ctime, any_value(DATE_FORMAT(create_time,'%Y-%m-%d-%H')) as chour, count(*) as hourNum
from game_log.player_login_log
where server_id = 196 and DATE_FORMAT(create_time,'%Y-%m-%d') >= '2021-03-03'
and DATE_FORMAT(create_time,'%Y-%m-%d') <= '2021-03-03' group by chour) t group by ctime ) t2
ON t1.day = t2.ctime ORDER BY t1.day
message:
### Error querying database. Cause: java.sql.SQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'game_log.player_login_log.create_time' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
### The error may exist in com/manage/dao/mapper/IReportMapper.java (best guess)
### The error may involve com.manage.dao.mapper.IReportMapper.game2-Inline
### The error occurred while setting parameters
### SQL: select t1.day, IFNULL(t2.avgNum,0) avgNum, IFNULL(t2.maxNum,0) maxNum from ( SELECT date_add( date_sub(?,interval 1 day), INTERVAL ( cast( help_topic_id AS signed ) + 1 ) day ) day FROM mysql.help_topic WHERE help_topic_id < DATEDIFF(?,date_sub(?,interval 1 day)) ) t1 LEFT JOIN ( select ctime, ROUND(sum(hourNum)/24) as avgNum, MAX(hourNum) as maxNum from ( select DATE_FORMAT(create_time,'%Y-%m-%d') ctime, DATE_FORMAT(create_time,'%Y-%m-%d-%H') chour, count(*) hourNum from game_log.player_login_log where server_id = ? and DATE_FORMAT(create_time,'%Y-%m-%d') >= ? and DATE_FORMAT(create_time,'%Y-%m-%d') <= ? group by chour ) t group by ctime ) t2 ON t1.day = t2.ctime ORDER BY t1.day
### Cause: java.sql.SQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'game_log.player_login_log.create_time' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'game_log.player_login_log.create_time' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
网上查出报错原因:
数据库设置了只读事务(保证了事务级别的读一致性),查询是一个事务的开始,但是在查询中有修改操作。
解决:
将运算部分查出,在代码里运算;
mysq 报错, sql语句在数据库里运行正常, 在内网测试正常,打包放外网的时候就报下面错误的更多相关文章
- 3,SQL语句及数据库优化
1,统一SQL语句的写法 对于以下两句SQL语句,程序员认为是相同的,数据库查询优化器认为是不同的. 所以封装成复用方法,用标准模板来控制. select*from dual select*Fr ...
- oracle 用sql语句管理数据库
基础sql语句 创建数据库 :create database database_name; 创建表:create table(字段名 字段类型 字段为空约束 ,字段名 字段类型 字段为空约束,,,, ...
- SQL语句及数据库优化
1,统一SQL语句的写法 对于以下两句SQL语句,程序员认为是相同的,数据库查询优化器认为是不同的. 所以封装成复用方法,用标准模板来控制. select*from dual select*Fro ...
- 2-06使用SQL语句创建数据库3
向现有数据库中添加文件组和数据文件几种方式以及步骤: 第一种:在视图下添加文件组和数据文件. 添加文件组的步骤: 右击你想要添加文件组的数据库点属性,然后点文件组就可以添加. 添加数据文件的步骤: 下 ...
- 使用SQL语句清空数据库所有表的数据
使用SQL语句清空数据库所有表的数据 近来发现数据库过大,空间不足,因此打算将数据库的数据进行全面的清理,但表非常多,一张一张的清空,实在麻烦,因此就想利用SQL语句一次清空所有数据.找到了三种方法进 ...
- 14.3.3 Locks Set by Different SQL Statements in InnoDB 不同的SQL语句在InnoDB里的锁设置
14.3.3 Locks Set by Different SQL Statements in InnoDB 不同的SQL语句在InnoDB里的锁设置 locking read, 一个UPDATE,或 ...
- SQL语句获取数据库中的表主键,自增列,所有列
SQL语句获取数据库中的表主键,自增列,所有列 获取表主键 1:SELECT TABLE_NAME,COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_U ...
- 【转载】C#常用数据库Sqlserver通过SQL语句查询数据库以及表的大小
在Sqlserver数据库中,一般我们查看数据库的大小可以通过查找到数据库文件来查看,但如果要查找数据表Table的大小的话,则不可通过此方法,在Sqlserver数据库中,提供了相应的SQL语句来查 ...
- mysql / pgsql 使用sql语句查询数据库所有表注释已经表字段注释
mysql使用sql语句查询数据库所有表注释已经表字段注释(转载) 场景: 1. 要查询数据库 "mammothcode" 下所有表名以及表注释 /* 查询数据库 ‘mammo ...
- SQL语句还原数据库并移动文件到指定路径
用SQL语句还原数据库时如果不指定数据库文件的存储路径,则默认把数据文件和日志文件存放到与原数据库相同的文件路径中,这样可能会产生错误,比如执行下面的语句: restore database Smar ...
随机推荐
- 第五章:用Python分析商品退单数据并找出异常商品
文章目录 项目背景 获取数据 数据计算 统计次数 异常商品 源码地址 本文可以学习到以下内容: 使用 pandas 中的 read_sql 读取 sqlite 中的数据 获取指定的日期的周一和周日 使 ...
- Netty实战学习笔记
第一部分 Netty的概念及体系结构 1.Netty异步和事件驱动 2.你的第一款Netty应用程序 3.Netty的组件和设计 4.传输 5.ByteBuf 6.ChannelHandler和Cha ...
- JUC续
设计模式,保护性暂停.解耦 生产者消费者模式 park.unpark 线程状态转换 锁超时 锁超时可以解决哲学家就餐问题 公平锁 条件变量 线程控制顺序
- autohotkey switching within applications
class QdirManager { ppid := -1 ppath := "" __New(pathIn) { this.ppath := pathIn } __Delete ...
- nginx 日志分析之 access.log 格式详解
说明:access.log 的格式是可以自己自定义,输出的信息格式在nginx.conf中设置 一般默认配置如下: http { ... log_format main '$remote_addr - ...
- Fedora 切换为阿里软件源
1.备份原软件源配置 cp /etc/yum.repos.d/fedora.repo /etc/yum.repos.d/fedora.repo.bak cp /etc/yum.repos.d/fedo ...
- 字符串散列成GUID
https://stackoverflow.com/questions/2190890/how-can-i-generate-a-guid-for-a-string
- python os.path模块函数功能
1.os.path.abspath(path) 获取绝对路径,实际上等于os.getcwd()+path 2.os.path.basename(path)取path最后的文件或文件名.如果path以/ ...
- struts2 显示表格
<%@ taglib uri="/struts-tags" prefix="s"%> <h3>All Records:</h3&g ...
- 学习Anaconda,jupyter notebook
20200210,理解了jupyter在anaconda中的意义,vs code觉得对我这个初学者来讲,更容易使用,pycharm虽然破解安装了,但是感觉不太好用,随后再说 20200211, jup ...