几天来,我一直在努力弄清楚如何使我的update
陈述发挥作用。该select
语句似乎按预期工作,但是当我尝试更新列值时出现ORA-01427 single-row subquery returns more than one row
错误。
这是代码:
UPDATE tbl_metrics
SET act_end_time = (WITH base
AS (SELECT caseid, entry_timestamp
FROM activity
WHERE act_id IN (100, 700, 300)
)
SELECT t1.entry_timestamp
FROM base t1, tbl_metrics t2
WHERE t1.caseid = t2.caseid
AND t2.act_start_time < (SELECT MIN(t1.entry_timestamp) FROM base t1 WHERE t1.caseid = t2.caseid))
这个想法是使用表中的最小值tbl_metrics.act_end_time
更新列,其中and是100、700 或 300。entry_timestamp
activity
activity.caseid=tbl_metrics.caseid
activity.entry_timestamp>tbl_metrics.act_start_time
activity.act_id