gpt4 book ai didi

postgresql - SQL 代码中的语法错误

转载 作者:行者123 更新时间:2023-11-29 12:22:21 25 4
gpt4 key购买 nike

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

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
^

最佳答案

试试这个:

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

关于postgresql - SQL 代码中的语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13621938/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com