我尝试执行查询并动态创建一个新列,其值取决于使用 case 语句的其他列。请注意,RATE 是表中不存在的新列。你能告诉我我错在哪里吗?
SELECT PAY_ATTR1.ID,
PAY_ATTR1.AMOUNT,
PAY_ATTR1.TAX,
ISSYNC = CASE WHEN PAY_ATTR1.AMOUNT != PAY_ATTR2.AMOUNT THEN 'DIFF' ELSE NULL END
FROM PAY_ATTR1
INNER JOIN PAY_ATTR2
ON PAY_ATTR1.ID=PAY_ATTR2.ID
ORA-00923:在预期位置找不到 FROM 关键字
SELECT PAY_ATTR1.ID,
PAY_ATTR1.AMOUNT,
PAY_ATTR1.TAX,
CASE WHEN PAY_ATTR1.AMOUNT != PAY_ATTR2.AMOUNT THEN 'DIFF' END as ISSYNC
FROM PAY_ATTR1
INNER JOIN PAY_ATTR2
ON PAY_ATTR1.ID=PAY_ATTR2.ID
SELECT PAY_ATTR1.ID,
PAY_ATTR1.AMOUNT,
PAY_ATTR1.TAX,
CASE WHEN PAY_ATTR1.AMOUNT != PAY_ATTR2.AMOUNT THEN 'DIFF'
ELSE NULL
END AS ISSYNC
FROM PAY_ATTR1 INNER JOIN PAY_ATTR2
ON PAY_ATTR1.ID = PAY_ATTR2.ID