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语句在数据库里运行正常, 在内网测试正常,打包放外网的时候就报下面错误的更多相关文章

  1. 3,SQL语句及数据库优化

       1,统一SQL语句的写法 对于以下两句SQL语句,程序员认为是相同的,数据库查询优化器认为是不同的. 所以封装成复用方法,用标准模板来控制. select*from dual select*Fr ...

  2. oracle 用sql语句管理数据库

    基础sql语句 创建数据库 :create database database_name; 创建表:create table(字段名 字段类型 字段为空约束 ,字段名 字段类型 字段为空约束,,,, ...

  3. SQL语句及数据库优化

     1,统一SQL语句的写法 对于以下两句SQL语句,程序员认为是相同的,数据库查询优化器认为是不同的. 所以封装成复用方法,用标准模板来控制. select*from dual  select*Fro ...

  4. 2-06使用SQL语句创建数据库3

    向现有数据库中添加文件组和数据文件几种方式以及步骤: 第一种:在视图下添加文件组和数据文件. 添加文件组的步骤: 右击你想要添加文件组的数据库点属性,然后点文件组就可以添加. 添加数据文件的步骤: 下 ...

  5. 使用SQL语句清空数据库所有表的数据

    使用SQL语句清空数据库所有表的数据 近来发现数据库过大,空间不足,因此打算将数据库的数据进行全面的清理,但表非常多,一张一张的清空,实在麻烦,因此就想利用SQL语句一次清空所有数据.找到了三种方法进 ...

  6. 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,或 ...

  7. SQL语句获取数据库中的表主键,自增列,所有列

    SQL语句获取数据库中的表主键,自增列,所有列   获取表主键 1:SELECT TABLE_NAME,COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_U ...

  8. 【转载】C#常用数据库Sqlserver通过SQL语句查询数据库以及表的大小

    在Sqlserver数据库中,一般我们查看数据库的大小可以通过查找到数据库文件来查看,但如果要查找数据表Table的大小的话,则不可通过此方法,在Sqlserver数据库中,提供了相应的SQL语句来查 ...

  9. mysql / pgsql 使用sql语句查询数据库所有表注释已经表字段注释

    mysql使用sql语句查询数据库所有表注释已经表字段注释(转载)   场景: 1. 要查询数据库 "mammothcode" 下所有表名以及表注释 /* 查询数据库 ‘mammo ...

  10. SQL语句还原数据库并移动文件到指定路径

    用SQL语句还原数据库时如果不指定数据库文件的存储路径,则默认把数据文件和日志文件存放到与原数据库相同的文件路径中,这样可能会产生错误,比如执行下面的语句: restore database Smar ...

随机推荐

  1. 2023-03-01 Error: Invalid hook call.Hooks can only be called inside of the body of a function component.

    问题描述:rn项目使用钩子useState,详细报错如下: Error: Invalid hook call. Hooks can only be called inside of the body ...

  2. Docker CLI docker run 常用命令

    Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中,然后发布到任何流行的 Linux或Windows操作系统的机器上,也可以实现虚拟化.Docker是内核 ...

  3. 如何为 Debian 11 安装图形用户界面 (GUI)

    如何为 Debian 11 安装图形用户界面 (GUI) allway2 于 2021-12-26 17:30:14 发布 11767 收藏 23文章标签: debian 服务器 linux版权 华为 ...

  4. 【记录】Linux Mint Cinnamon Desktop Enviroment使用记录

    之前使用的系统是Kali Linux,并不是看上了一堆工具,工具的话上虚拟机不好吗,会折腾的docker更好阿,主要是 1. 用习惯了gnome的桌面环境 2. 开箱即用 很多配置他都已经做好了 我都 ...

  5. 日常开发记录-Object函数的内置方法Object.entries

    方法1: const data = { id: 1, name: "张三", age: 22 } let params = "" /* Object.entri ...

  6. 攻防世界-unseping(序列化,Bash shell)

    这是一道序列化的题目,结合了Linux Bash shell知识 一.基础知识点 序列化    序列化的概念:    序列化 (Serialization)是将对象的状态信息转换为可以存储或传输的形式 ...

  7. [Oracle19C 数据库管理] 配置数据库审计

    以下内容未经整理 占位 强制审计:无法关闭此审计,比如记录数据库的开启和关闭. 标准审计: 基于值得审计:创建触发器,基于值进行记录.Trigger占用资源多 细粒度审计:加一些where条件,针对触 ...

  8. vue-awesome-swiper使用中的一些问题

    项目中使用了vue-awesome-swiper,发现autoplay不能用.网上找了半天,说是版本问题.最后在main.js中添加以下代码解决. import VueAwesomeSwiper fr ...

  9. Visual C++ Redistributable for Visual Studio各版本下载地址

    Visual C++ Redistributable for Visual Studio各版本下载地址飞鹰_天涯于 2021-06-24 09:35:21 发布 5978收藏 8版权Microsoft ...

  10. python 中的 re.compile 函数

    python 中的 re.compile 函数   正则表达式功能十分强大. "有些人面临一个问题时会想:'我知道,可以用正则表达式来解决这个问题.'于是现在他们就有两个问题了"- ...