Copy all cancelled orders into a new table archived(id, customer_id) with INSERT … SELECT, and RETURN the copied rows.
Copy all cancelled orders into a new table archived(id, customer_id) with INSERT … SELECT, and RETURN the copied rows.
Answer
CREATE TABLE archived (id int, customer_id int); INSERT INTO archived SELECT id, customer_id FROM orders WHERE status = 'cancelled' RETURNING *;