3

我遇到了一个奇怪的语法错误,请帮助我解决它。

WITH A as (
SELECT ambtemp,
       date_trunc('hour', dt)+
       CASE WHEN date_part('minute', dt) >= 30
            THEN interval '30 minutes'
            ELSE interval '0 minutes'
       END as t
FROM temm),

B as(
SELECT ambtemp,t,

       max(ambtemp::float(23)) OVER (PARTITION BY t) as max_temp,
       min(ambtemp::float(23)) OVER (PARTITION BY t) as min_temp
FROM A),


 H AS (
SELECT *      
FROM B
WHERE (max_temp - min_temp) <= 0.2 )

UPDATE temm
SET ambtemp = (NULL)
WHERE dt IN H

正如您在代码中看到的,所有代码都正常运行,除了“WHERE dt IN H”,当我忽略这部分代码运行但存在代码时,我遇到了以下错误:

ERROR:  syntax error at or near "H"
LINE 25: WHERE dt IN H
                     ^
4

1 回答 1

2

尝试这个:

UPDATE temm
SET ambtemp = (NULL)
WHERE dt IN ( SELECT ambtemp FROM H )
于 2012-11-29T09:06:34.383 回答