我需要帮助解决这个问题。 “在1950年,这是观看次数最高的电影,并且根据该电影的用户职业被评为5级,并且很多人看过该电影;”
我收到关注错误
“ SemanticException [错误10128]:行1:56 UDAF'MAX'尚不支持的位置”

movie_name, year, rating, occupation, views
A   1950    1   teacher 52
B   1953    5   doctor  45
C   1950    1   teacher 85
D   1952    4   police  35
E   1951    2   lawyer  15
F   1950    3   doctor  26
G   1951    1   lawyer  53
H   1952    2   teacher 85
I   1951    4   police  45
J   1950    3   doctor  36
K   1953    1   lawyer  52
L   1951    5   police  62
M   1953    2   teacher 42
N   1950    4   lawyer  85
O   1951    3   police  9
P   1952    1   doctor  44
Q   1950    5   teacher 27
R   1951    2   police  86
S   1955    3   lawyer  51
T   1950    5   police  49
U   1955    4   teacher 86
V   1954    3   lawyer  99
W   1951    2   teacher 84
X   1955    5   police  72
Y   1954    2   teacher 62
Z   1950    4   doctor  85

最佳答案

您不能在where子句中使用聚合表达式;订购结果应该足够了。

SELECT movie_name, occupation, views
FROM movie
WHERE year = 1950 AND rating = 5
ORDER BY views DESC
LIMIT 1

关于mysql - 从电影中选择职业,年份为1950年AND评级为5 AND MAX(观看次数);,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33159857/

10-11 03:21