Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个与电影相关的表格,其中包含以下列。
id, year, score
首先,我需要显示我已经完成的每年的平均分数。
SELECT year, AVG(score) FROM movies GROUP BY year DESC;
但现在我需要做同样的事情,但仅限于每年 id (计数)高于 1 的情况。
你是这个意思吗?
Select Year, AVG(score) FROM movies GROUP BY year HAVING count(*) > 1 ORDER BY year desc;
descon的使用group by是非常特定于 MySQL 的。我认为最好有一个明确的order by.
desc
group by
order by