with ntable (date,pnodeid,rtavg)
as
(
select date,pnodeid, (select avg(myaverage) from (values (hour8),(hour9),(hour10),(hour11),(hour12),(hour13),(hour14),(hour15),(hour16),(hour17),(hour18),(hour19),(hour20),(hour21),(hour22),(hour23)) as TblAverage(myaverage)) from pjm_realtime
)
select date,rtavg
from ntable
where rtavg > 65 and pnodeid = '51288' and weekday(date) between 0 and 4 and year(date) >= '2014';
我得到1064錯誤。試圖獲得多列的平均值並將其用作搜索條件語法錯誤意外與
MySQL沒有CTE。 – Nicarus