我的查询,
WITH vista AS (
SELECT
transaction_id,
SUM (item_total) AS items_total,
SUM (item_total) * 0.2 AS discount_value,
(SUM (item_total) * 0.8) * 0.16 AS tax,
(SUM (item_total) * 0.8 * 1.16) AS grand_total
FROM lineitems_vista
GROUP BY transaction_id
)
UPDATE transactions
SET
items_total = vista.items_total,
discount_id = 5,
discount_value = vista.discount_value,
tax = vista.tax,
grand_total = vista.grand_total
FROM vista
WHERE id = transaction_id;
只更新了302行,现在已经持续了大约一个小时。我做错了什么?