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;
しかし今、私は同じことをする必要がありますが、1 年あたりの 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