国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

數據庫中的聚合函數

2024-07-21 02:52:37
字體:
來源:轉載
供稿:網友

常用的聚合函數 1 count 2 sum 3 avg 4 max 5 min 使用規范時 默認的是all distinct 指定所有的唯一非空值行 count (行的數目) select count ( 列或者*) from 表 sum (總和) select sum(計數規范)from

分組 (group by) select 列a , 聚合函數 from 表 where 過濾條件 group by 列a (以列a來分組)

過濾聚合函數(having) select 列a , 聚合函數 from 表 where 過濾條件 group by 列a having 聚合函數過濾條件

要注意的是 SQL語句的執行順序 (5)select 列a , 聚合函數 (1) from 表 (2) where 過濾條件 (3) group by 列a (4) having 聚合函數過濾條件 (6) order by

課后練習 select * from nobel – 1獲獎總人數 select count (distinct winner) from nobel – 2 諾貝爾 物理獎的獲獎總次數 select count(subject)from nobel where subject=’Physics’ – 3 顯示每個獎項的獲獎總次數 select subject,count(subject)from nobel group by subject – 4顯示每個獎項第一次獲得的年份 select min(yr) 年份,subject 獎項 from nobel group by subject – 5 顯示每個獎項在2000年來獲得的人數 select subject 獎項,yr 年份 from nobel where yr=2000 group by subject ,yr – 6 顯示每個獎項不同獲獎者的人數 select subject 獎項,count (distinct winner)from nobel group by subject – 7 顯示每個獎項 有多少年獲獎 select subject 獎項,count (distinct yr)from nobel group by subject – 8 顯示當年有三個Physic的年份 select subject 獎項,yr 年份 from nobel where subject=’Physics’ group by yr, subject having count(winner)=3 – 9 得獎大于1的winner select winner 獲獎者 from nobel group by winner having count(subject)>1 –10 得到多個獎項的winner select winner 獲獎者 from nobel group by winner having count(distinct subject)>1 –11


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 法库县| 那曲县| 黄陵县| 屏东县| 德阳市| 浪卡子县| 犍为县| 阿巴嘎旗| 昭觉县| 从江县| 彝良县| 桐乡市| 即墨市| 富裕县| 南靖县| 绩溪县| 大宁县| 墨脱县| 开原市| 合作市| 安多县| 玉龙| 朝阳县| 绍兴市| 常宁市| 娱乐| 天台县| 松江区| 保康县| 宁远县| 蕉岭县| 喜德县| 桐乡市| 宜阳县| 宜昌市| 二连浩特市| 唐海县| 宁城县| 淮南市| 西平县| 镇康县|