Even copy and pasting brings an error (SQL)

Screen Link:

My Code:

    SELECT
        c.*
    FROM chinook.invoice i
    INNER JOIN chinook.customer c ON i.customer_id = c.customer_id
    GROUP BY 1
    HAVING SUM(i.total) > 90;
SELECT * FROM chinook.customer_gt_90_dollars; ```



What I expected to happen:
The code to run

What actually happened: 

(sqlite3.OperationalError) table customer_gt_90_dollars already exists
[SQL: CREATE VIEW chinook.customer_gt_90_dollars AS SELECT c.* FROM chinook.invoice i INNER JOIN chinook.customer c ON i.customer_id = c.customer_id GROUP BY 1 HAVING SUM(i.total) > 90;]
(Background on this error at: http://sqlalche.me/e/e3q8)


<!--Enter other details below: -->
I saw a similar question regarding python not running despite a copy & pasted solution being used. I tried refreshing my page as suggested in that thread, to no avail.

As the error states -

The table already exists. Which most likely happened because you already ran the query Create View once. Running it again produces the above error.

If you wish to perform further queries on that table, then you will have to remove the Create View query.

Thank you. I believe this is the solution – although when I loaded up the mission today (12 hours later), I didn’t need to drop the view, I guess something rebooted after a period of inactivity. Thanks again though

1 Like

I found a solution was to run the drop view and create view sequentially.:.

DROP VIEW chinook.customer_gt_90_dollars;

CREATE VIEW chinook.customer_gt_90_dollars AS
SELECT c.* FROM chinook.invoice AS I
INNER JOIN customer AS c ON c.customer_id = i.customer_id
GROUP BY c.customer_id
HAVING SUM(i.total) >90;
SELECT * FROM chinook.customer_gt_90_dollars;

Yea, I managed to find that too. But thanks for posting the complete code, I imagine it may be useful to have posted here