• 请不要在回答技术问题时复制粘贴 AI 生成的内容
tboy
0D
V2EX  ›  程序员

求当天两小时间间隔 平均值的 MYSQL 语句

  •  
  •   tboy · May 16, 2016 · 4474 views
    This topic created in 3825 days ago, the information mentioned may be changed or developed.

    当前两小时间 时间价格的平均值的 MYSQL 语句

    结果 12 条数据,每天都是两个小时的平均值 比如第一条是 0:00-2:00 ;第二条是 2:00-4:00,如果当前间隔没数据,沿用上间隔的平均值

    2 replies  •  2016-05-16 15:45:12 +08:00
    haranhuang
    haranhuang
    May 16, 2016
    1
    select floor(hour(time)/2) as hourgroup,avg(a)
    from table
    group by floor(hour(time)/2)
    tboy
    tboy
    OP
    May 16, 2016
    2
    @haranhuang 谢谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2621 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:08 · PVG 22:08 · LAX 06:08 · JFK 09:08
    ♥ Do have faith in what you're doing.