我正在尝试从下面的两个表计算访问次数:
宠物桌:
访问表:
这是我的SQL
:
SELECT pet_name, pet_type
FROM pets p
JOIN visits v
ON p.petid = v.petid
SELECT COUNT(petid) AS "NUMBER OF VISITS" FROM visits
WHERE petid = "PT5"
它返回此错误消息:
ORA-00933: SQL command not properly ended
有什么想法我做错了吗?
最佳答案
SELECT p.pet_name, p.pet_type, COUNT(v.petid) AS "NUMBER OF VISITS"
FROM pets p
JOIN visits v ON p.petid = v.petid
WHERE p.petid = "PT5"
GROUP BY p.pet_name, p.pet_type