Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax Error In SQL Code

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
                     ^
like image 532
A.Amidi Avatar asked Jul 17 '26 18:07

A.Amidi


1 Answers

try this:

UPDATE temm
SET ambtemp = (NULL)
WHERE dt IN ( SELECT ambtemp FROM H )
like image 178
user1733773 Avatar answered Jul 20 '26 09:07

user1733773



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!