我试图计算下面这两张表中的访问次数:
宠物餐桌:
访问表:
这是我的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
任何想法我做错了什么?
答案 0 :(得分:2)
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