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.
MYSQL で以下をどのように記述できますか?
SELECT AVG(col1) FROM table WHERE DISTINCT col2
より詳しい情報:
table col1 | col2 ----------- 2 | 555.555.555.555 5 | 555.555.555.555 4 | 444.444.444.444
「3」を返します
基本的に、 col2のIP アドレスが異なるcol1の平均値を選択しようとしています。
SELECT col2, AVG(col1) FROM table GROUP BY col2
そうです、distinct句は1行目と3行目を見つけるので、2と4の平均は3です。
あなたが探しているのは、個別ではなく「groupbycol2」です。
group byオペレーターが欲しいと思います。計算を実行する前に行をグループ化します。
group by