日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql 学习笔记05 统计函数的相关使用

發布時間:2023/11/30 数据库 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 学习笔记05 统计函数的相关使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
  • 合計函數count, 統計多少條記錄
  • 統計共有多少學生 select count(*) from students; 查詢數學成績大于等于90的學生數量 select count(*) from students where math >= 90; 查詢總分超過235分的學生的數量 select count(*) from students where (English + math + China) >= 90;

    注意:count(*)與count(某個字段)的區別:

    2. 合計函數 sum , 計算數值的和

    統計一個學生表, 數學總分 select sum(math) as 'mathTotalScore' from students; 統計一個學生表, 數學總分,語文總分,英語總分 select sum(math) as 'mathTotalScore', sum(China) as 'ChinaTotalScore', sum(English) as 'EnglishTotalScore' from students; 統計 數學英語語文,三個科目的成績總和 select sum(math) + sum(English) + sum(China) from students; (推薦) select sum(math+English+China) from students;(不推薦,這樣只有某個學生,的一科成績為null,這個學生的成績就統計不進去) 統計一個班的語文平均分 select round(sum(China)/count(name) ,2) as '語文平均分' from students;
  • 合計函數 avg,返回滿足where條件的一列的平均值
  • 求一個學生表的數學平均分 select avg(math) as 'avgmath' from students; 如果有9個人,其中一個人math為null, 那么這個語句實際上,是 計算的數學總分/8 盡量讓自己的數據為not null 求一個班級的總分平均 select avg(math + English + China) as 'avgFor_totalScore' from students;
  • 合計函數max 與 min
  • 求一個班級 最高分 與 最低分 select max(math + English + China) , min(math + English + China) from students;

    總結

    以上是生活随笔為你收集整理的mysql 学习笔记05 统计函数的相关使用的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。