我想根据某种条件通过合并其他三个表来更新一个表。 losid在所有三个表中都很常见。我的查询如下:
UPDATE "rpChange"."rpChanget" AS a
SET "hold" = CASE
WHEN status"."losid" IS NULL and mUpdate."losid" IS NULL and dealer."losid" IS NULL
THEN 'N'
WHEN (status."losid" IS NOT NULL and COALESCE(age(NOW(), status."updateDt"),age(NOW(), status."createDt")) < '30 minutes' and status."publishedYN"='Y') or
(mUpdate."losid" IS NOT NULL and COALESCE(age(NOW(), mUpdate."updateDt"),age(NOW(), mUpdate."createDt")) < '30 minutes' and mUpdate."publishedYN"='Y') or
(dealer."losid" IS NOT NULL and COALESCE(age(NOW(), dealer."updateDt"),age(NOW(), dealer."createDt")) < '30 minutes' and dealer."publishedYN"='Y')
THEN 'Y'
END
,"holdR" = CASE
WHEN status."losid" IS NULL and mUpdate."losid" IS NULL and dealer."losid" IS NULL
THEN NULL
WHEN (status."losid" IS NOT NULL and COALESCE(age(NOW(), status."updateDt"),age(NOW(), status."createDt")) < '30 minutes' and status."publishedYN"='Y') or
(mUpdate."losid" IS NOT NULL and COALESCE(age(NOW(), mUpdate."updateDt"),age(NOW(), mUpdate."createDt")) < '30 minutes' and mUpdate."publishedYN"='Y') or
(dealer."losid" IS NOT NULL and COALESCE(age(NOW(), dealer."updateDt"),age(NOW(), dealer."createDt")) < '30 minutes' and dealer."publishedYN"='Y')
THEN 'SCHEDULED FOR LATER'
END
FROM "statuss"."statusSt" AS status
,"mUpdates"."mUpdateSt" AS mUpdate
, "dealers"."dealerSt" AS dealer
WHERE status."losid" = a."losid"
AND mUpdate."losid" = a."losid"
AND dealer."losid" = a."losid";
以上查询在添加COALESCE()之前有效,但添加后会引发语法错误。谁能帮我,这是怎么了。