Creating a copy of table

CREATE TABLE invoices_archieved AS
SELECT *
From invoices;

INSERT INTO invoices_archieved
SELECT *
From invoices
Where payment_date IS NOT NULL;

SELECT *
FROM invoices_archieved I
JOIN clients C
ON C.name = I.client_id

Is this code is correct for the example? When i run this code no error but the Join operator didn’t worked, not replacing name with client id. :face_with_monocle:

It didn’t work because you are joining on name and id.

Since name and id never have matching values the result will be empty.

And you will want to revisit the excercise. We didn’t want the invoices_archived table to be a 1:1 copy of the invoices table. We wanted to have a name column with the clients name in invoices_archived instead of the original client_id column of the invoices table.emphasized text

1 Like

Thank Sam, I got it.