别名在MySQL中不起作用?别名何时生效?

时间:2019-12-28 01:41:33

标签: mysql sql

我想从表格中获得最大访问人数, 但出现错误Table 'test.VisitCount' doesn't exist 我相信别名VisitCount不起作用。 如何解决?

这是我的代码:

SELECT CharName, Movie, Counts
FROM 
(
    SELECT TT.Character_Name AS CharName, TT.Movie AS Movie, COUNT(*) AS Counts
    FROM TimeTable TT
    GROUP BY TT.Character_Name, TT.Movie
) AS VisitCount 
WHERE Counts = (SELECT MAX(Counts) FROM VisitCount);

0 个答案:

没有答案