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

歡迎訪問 生活随笔!

生活随笔

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

数据库

mysql基础(3)-高级查询

發(fā)布時間:2025/1/21 数据库 115 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql基础(3)-高级查询 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

聚合函數(shù) count 返回查詢結果的條數(shù) max 返回查詢結果的最大值 min 返回查詢結果的最小值 sum 返回查詢結果的和 avg 返回查詢結果的平均值 統(tǒng)計分數(shù)大于等于90的人數(shù): mysql>?select?count(*)?from?new_student ? ? ? ? ->?where?score?>="90";? 使用distinct剔除字段值重復的條數(shù) mysql>?select?count(distinct?score)?from?new_student ? ? ? ? ->?where?score?>="90"; 統(tǒng)計最高分-max mysql>?select?max(score)?from?new_student;
統(tǒng)計最低分-min mysql>?select?min(score)?from?new_student; ?mysql>?select?min(score)?from?new_student ? ? ? ? ->?where?score?>=60; 統(tǒng)計分數(shù)大于等于90的分數(shù)的和-sum ?mysql>?select?sum(score)?from?new_student ? ? ? ? ->?where?score?>="90"; 統(tǒng)計平均數(shù)-avg ?mysql>?select?avg(score)?from?new_student ? ? ? ? ->?where?score?>="80"; 分組查詢 語法格式; select [聚合函數(shù)] 字段名 from 表名 where 查詢條件 group by 字段名 having 過濾條件 mysql>?select?score,count(*)?from?new_student ? ? ? ? ->?where?score?>=80 ? ? ? ? ->?group?by?score; mysql>?select?score,count(*)?from?new_student ? ? ? ? ->?where?score?>=80 ? ? ? ? ? ?? ? ? ? ? ->?group?by?score ? ? ? ? ->?having?score?>=90; 注:having子語句與where子語句區(qū)別:前者在分組后對記錄進行過濾,后者在分組前對記錄進行過濾 mysql>?select?score,count(*)?from?new_student ? ? ? ? ->?where?score?>=80 ? ? ? ? ->?group?by?score ? ? ? ? ->?having?score?>=90 ? ? ? ? ->?order?by?score?desc; 聯(lián)合查詢 語法格式 select 語句 union [all] select 語句 ... ?注:聯(lián)合查詢結果使用第一個select語句中的字段名 mysql>?select?*?from?test_wl ? ? ? ? ->?union ? ? ? ? ->?select?*?from?test_wu;

?

轉載于:https://www.cnblogs.com/wujiadong2014/p/5717198.html

總結

以上是生活随笔為你收集整理的mysql基础(3)-高级查询的全部內容,希望文章能夠幫你解決所遇到的問題。

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