Oracle SQL“找不到FROM关键字”

时间:2016-12-13 01:17:03

标签: sql oracle

当我尝试运行以下语句时,我一直收到“找不到预期的FROM关键字”错误指向第1行:

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;

该错误特别突出显示Patient_ID)),我无法弄清楚修复。

1 个答案:

答案 0 :(得分:1)

它是(SELECT COUNT(DISTINCT patient_id)),奇怪的是,它没有FROM关键字:-)。我认为你真的应该丢失SELECT并且只有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;