2016-08-18 10 views
-2
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エラーが発生しています。複数の列の平均を取得して検索条件として使用しようとしています予期しない構文エラー

+3

MySQLにはCTEがありません。 – Nicarus

答えて

0

MySQLにはCTE/WITHはありません。しかし、あなたは、単にそのように副問合せができます。

select date, rtavg 
from 
( 
    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)) rtavg from pjm_realtime 
) btable 
where rtavg > 65 and pnodeid = '51288' and weekday(date) between 0 and 4 and year(date) >= '2014'; 
+0

助けてくれてありがとう –

0

WITH構文は、MySQLがサポートされていないSQL-99の機能です。

私はここに機能の欠如について書いた:2016年4月にはWITHer Recursive Queries?

を、私は、MySQLの開発スタッフのパネルにより、プレゼンテーションに行って、彼らは次のメジャーバージョンでWITH構文をサポートする予定と述べ、しかし、それはおそらく2、3年間は準備ができていないでしょう。

関連する問題