I have faced with a strange syntax error plz help me to solve it.
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
As you can see in the code, all the code ran properly except " WHERE dt IN H" and when I i ignore this part code runs but in the presence of the code I faced with following error:
ERROR: syntax error at or near "H"
LINE 25: WHERE dt IN H
^
WHERE dt IN (SELECT * FROM H), but this won't work, since H has multiple columns. What are you trying to do, exactly?