3

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
                     ^
3
  • Normally, I'd suggest WHERE dt IN (SELECT * FROM H), but this won't work, since H has multiple columns. What are you trying to do, exactly? Commented Nov 29, 2012 at 8:55
  • @MarceloCantos, YEs, I get in to this error: ERROR: subquery has too many columns LINE 25: WHERE dt IN (SELECT * FROM H) Commented Nov 29, 2012 at 9:01
  • It's difficult to help you without some idea of what you are trying to do. Commented Nov 29, 2012 at 9:03

1 Answer 1

2

try this:

UPDATE temm
SET ambtemp = (NULL)
WHERE dt IN ( SELECT ambtemp FROM H )
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.