根据customer_po = ID
上的自联接更新表表XYZ
ID Invoice Date Delivery_date Customer_po
123 01-01-2018 null null
125 10-01-2018 null 123
我想在Oracle SQL
中输出如下所示的输出记录ID Invoice Date Delivery_date Customer_po
123 01-01-2018 01-01-2018 null
125 10-01-2018 01-01-2018 123
答案 0 :(得分:1)
您需要这样的更新声明。
UPDATE xyz
SET Delivery_date =
(SELECT MAX (invoice_date)
FROM xyz
WHERE Customer_po = 123);
请注意,我使用MAX
来避免因Customer_po = 123