V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
MySQL 5.5 Community Server
MySQL 5.6 Community Server
Percona Configuration Wizard
XtraBackup 搭建主从复制
Great Sites on MySQL
Percona
MySQL Performance Blog
Severalnines
推荐管理工具
Sequel Pro
phpMyAdmin
推荐书目
MySQL Cookbook
MySQL 相关项目
MariaDB
Drizzle
参考文档
http://mysql-python.sourceforge.net/MySQLdb.html
ningxiaoxiao
V2EX  ›  MySQL

sql 平均值为什么要 full group by??

  •  
  •   ningxiaoxiao · 2022-04-29 21:46:19 +08:00 · 1845 次点击
    这是一个创建于 726 天前的主题,其中的信息可能已经有所发展或是发生改变。

    sql 平均值为什么要 full group by??

    5 条回复    2022-09-09 15:37:34 +08:00
    littlewing
        1
    littlewing  
       2022-04-29 22:15:28 +08:00   ❤️ 1
    oneisall8955
        2
    oneisall8955  
       2022-04-29 22:50:46 +08:00 via Android
    你把 sql 简化贴出来,或许你写错了吧
    ningxiaoxiao
        3
    ningxiaoxiao  
    OP
       2022-04-30 12:48:20 +08:00
    就是想求 在一个时间点里,以 army_id 为组的 x 的平均值,
    SELECT
    avg(x) as ax,
    avg(y) as ay,
    avg(z) as az,
    FROM
    `path`
    WHERE
    `space` = 'xxxxxxx'
    GROUP BY army_id
    ORDER BY
    `game_time`,
    `team_num`,
    `team_position`

    [![LzI2FJ.png]( https://s1.ax1x.com/2022/04/30/LzI2FJ.png)]( https://imgtu.com/i/LzI2FJ)
    NoahVI
        4
    NoahVI  
       2022-09-09 15:37:08 +08:00
    你写的 sql 不规范,group by 的字段 需要在聚合函数里面用到
    NoahVI
        5
    NoahVI  
       2022-09-09 15:37:34 +08:00
    @NoahVI 或者把 sql_mode 改一下。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2884 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 15:28 · PVG 23:28 · LAX 08:28 · JFK 11:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.