看板 Database 關於我們 聯絡資訊
資料庫名稱:MySQL 資料庫版本:10 內容/問題描述: 時間 資料數值 1/1 100 1/2 200 1/3 300 1/4 50 1/5 100 請問我想要用一行指令算出 1/1~1/2的平均,1/3~1/4的平均,1/1~1/5的平均 請問該怎麼用? 目前想到的只有分成三個select 然後union起來才能在一次搜尋內做到 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.227.151.121 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Database/M.1647323031.A.56C.html
criky: select avg(case when date between 1/1 and 1/2 then data 03/18 06:51
criky: else null end),avg (case when date between 1/3 and 1/4 03/18 06:51
criky: then sata else null end),avg(data) from table 03/18 06:51