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