NewPythonUser
NewPythonUser

Reputation: 47

Oracle SQL "FROM keyword not found where expected"

I keep getting the "FROM keyword not found where expected" error pointing at line 1 when I try to run the following statement:

SELECT Physician.Last_Name, Physician.First_Name, (SELECT COUNT (DISTINCT Patient_ID)), AS Unique_PTS
FROM Visit
JOIN Physician
          ON Visit.Physician_ID = Physician.Physician_ID
GROUP BY Physician.Last_Name, Physician.First_Name
ORDER BY Unique_PTS DESC;

The error specifically highlights Patient_ID))and I'm having trouble figuring out the fix.

Upvotes: 0

Views: 317

Answers (1)

DCookie
DCookie

Reputation: 43533

It's the (SELECT COUNT(DISTINCT patient_id)), which oddly enough, does not have a FROM keyword :-). I presume you really should lose the SELECT and just have COUNT(DISTINCT patient_id).

SELECT Physician.Last_Name, Physician.First_Name, COUNT (DISTINCT Patient_ID) AS Unique_PTS
FROM Visit
JOIN Physician
          ON Visit.Physician_ID = Physician.Physician_ID
GROUP BY Physician.Last_Name, Physician.First_Name
ORDER BY Unique_PTS DESC;

Upvotes: 0

Related Questions