Data Science | Cumulative SQL Project


#1

Hi all,

following the Data Science Path I got stuck doing the Cumulative SQL Project at the end of the ‘SQL:Intermediate’ part. The problem occurs at task 4 with the following line of code:

CREATE TABLE inactive_patients
AS (SELECT * 
    FROM patients 
    WHERE Status = "inactive");

which throws a syntax error near the first parenthesis. This is very confusing since the code does obey SQL syntax. Moreover, this is the same syntax as in the hint given for this task. What’s wrong here?

Here is a screenshot:

I am using an early 2011 MacBook Pro with Mac OS High Sierra and Safari 12.0.

Thanks, everyone!


SQL Cumulative Project
Analyzing heart disease
#2

Sorry I don’t have a solution, but chiming in to say I’m having the same issue. On a Windows 10 PC, using Google Chrome.


#3

I cannot seem to find any relative data on CREATE TABLE AS.
It looks like it depends on the database.
I could find the following, apparently it’s the preferred method?

SELECT * INTO newTable 
FROM (SELECT * from otherTable);

Maybe a moderator can help with the solution.


#4

Well I found the solution - there should be no parentheses involved with the CREATE TABLE AS statement. If you copy the hint, you must remove the parentheses.


#5

Thanks a lot! At first, it seemed a little odd to me, but I think you are right. I checked the SQLite documentation and it backs your solution.
As a reference: the version using parenthesis is documented here.

I hope someone will clear this up in the project.


#6

Thank you. I just hit the same roadblock, and removing the parentheses worked for me.


#7

Thanks for your solution - I had the same problem and it was driving me crazy. I finally googled it and got here. I am surprised that no moderator answered.