我得到一个"错误:ORA-00928:缺少SELECT关键字"运行以下查询时出现错误消息。
查询的目的是获取每个十年中大多数电影中加星标(由星号表示,如ord = 1所示)的演员的名字。
我独立测试了T1和T2并且它们起作用。我不明白我做错了什么。
你能帮我解释一下吗?
注意:这是家庭作业
WITH T1 AS
(SELECT decade, MAX(countTitle) maxCount
FROM (
SELECT FLOOR(yr/10)*10 decade, name, COUNT(title) countTitle
FROM movie JOIN casting ON (movie.id = casting.movieid)
JOIN actor ON (actor.id = casting.actorid)
WHERE (casting.ord = 1)
GROUP BY FLOOR(yr/10)*10, name
)
GROUP BY decade)
T2 AS
(SELECT decade, MAX(countTitle) maxCount
FROM T1)
T3 AS
(SELECT FLOOR(yr/10)*10 decade, name, COUNT(title) countTitle
FROM movie JOIN casting ON (movie.id = casting.movieid)
JOIN actor ON (actor.id = casting.actorid)
WHERE (casting.ord = 1)
GROUP BY FLOOR(yr/10)*10, name
)
SELECT T3.decade, T3.name, T3.countTitle
FROM T2 INNER JOIN T3
ON T3.decade = T2.decade AND T3.countTitle = T2.maxCount;
答案 0 :(得分:1)
你不需要在T i 之间使用逗号吗?