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

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

  •  
  •   tboy · May 16, 2016 · 4068 views
    This topic created in 3668 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
        1
    haranhuang  
       May 16, 2016
    select floor(hour(time)/2) as hourgroup,avg(a)
    from table
    group by floor(hour(time)/2)
    tboy
        2
    tboy  
    OP
       May 16, 2016
    @haranhuang 谢谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   967 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 5414617a · 40ms · UTC 20:01 · PVG 04:01 · LAX 13:01 · JFK 16:01
    ♥ Do have faith in what you're doing.