<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
以mysql為例,彙總sql查詢最高分、最低分、平均分等sql語句,oracle語法類似,可自行修改以下sql語句
建立兩個資料庫表,一個學生表、一個考試成績表
DROP TABLE IF EXISTS `score`; CREATE TABLE `score` ( `u_id` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '編號', `object_no` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '課程編號', `students_no` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '學號', `score` int(11) NULL DEFAULT NULL COMMENT '分數' ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; INSERT INTO `score` VALUES ('1', '100', 's100', 80); INSERT INTO `score` VALUES ('2', '100', 's200', 59); INSERT INTO `score` VALUES ('3', '100', 's300', 79); INSERT INTO `score` VALUES ('4', '200', 's100', 54); INSERT INTO `score` VALUES ('5', '200', 's200', 96); INSERT INTO `score` VALUES ('6', '200', 's300', 74); INSERT INTO `score` VALUES ('7', '300', 's100', 65); INSERT INTO `score` VALUES ('8', '300', 's200', 80); INSERT INTO `score` VALUES ('9', '200', 's400', 62); INSERT INTO `score` VALUES ('10', '300', 's400', 56); INSERT INTO `score` VALUES ('11', '100', 's400', 70); SET FOREIGN_KEY_CHECKS = 1; DROP TABLE IF EXISTS `students`; CREATE TABLE `students` ( `students_no` varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '編號', `students_name` varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '姓名', `sex` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '性別', PRIMARY KEY (`students_no`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; INSERT INTO `students` VALUES ('s100', '張三', '1'); INSERT INTO `students` VALUES ('s200', '李四', '2'); INSERT INTO `students` VALUES ('s300', '張三', '1'); INSERT INTO `students` VALUES ('s400', '王五', '1'); SET FOREIGN_KEY_CHECKS = 1;
select object_no as '課程編號', count(DISTINCT students_no) '考試人數' from score group by object_no
select object_no as '課程編號',max(score) as '最高分',min(score) as '最低分' from score group by object_no
查詢每門課程被選修的學生數
select object_no as '課程編號', count(DISTINCT students_no) as '學生編號' from score group by object_no
select sex '性別',count(DISTINCT students_no) '數量' from students group by sex
select students_no as '學生編號',avg(score) as '平均成績' from score group by students_no
select students_no as '學生編號',avg(score) as '平均成績' from score group by students_no HAVING avg(score)>70
select students_no as '學生編號',count(object_no) as '課程編號' from score group by students_no
select students_no as '學生編號',count(object_no) as '課程編號' from score group by students_no HAVING count( object_no)>2
select students_name as '學生名稱',count(students_name) as '同名數量' from students group by students_name HAVING count(students_name)>1
select object_no as '課程編號',avg(score) as '平均成績' from score group by object_no
select object_no as '課程編號',avg(score) as '平均成績' from score group by object_no HAVING avg(score)>70
select object_no as '課程編號',students_no '學生編號',score '分數' from score where score<60 order by object_no desc
select object_no as '課程編號',avg(score) as '平均成績' from score group by object_no order by avg(score) desc,object_no asc
到此這篇關於sql查詢語句之平均分、最高最低分及排序語句的文章就介紹到這了,更多相關mysql平均分查詢語句內容請搜尋it145.com以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援it145.com!
相關文章
<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
综合看Anker超能充系列的性价比很高,并且与不仅和iPhone12/苹果<em>Mac</em>Book很配,而且适合多设备充电需求的日常使用或差旅场景,不管是安卓还是Switch同样也能用得上它,希望这次分享能给准备购入充电器的小伙伴们有所
2021-06-01 09:31:42
除了L4WUDU与吴亦凡已经多次共事,成为了明面上的厂牌成员,吴亦凡还曾带领20XXCLUB全队参加2020年的一场音乐节,这也是20XXCLUB首次全员合照,王嗣尧Turbo、陈彦希Regi、<em>Mac</em> Ova Seas、林渝植等人全部出场。然而让
2021-06-01 09:31:34
目前应用IPFS的机构:1 谷歌<em>浏览器</em>支持IPFS分布式协议 2 万维网 (历史档案博物馆)数据库 3 火狐<em>浏览器</em>支持 IPFS分布式协议 4 EOS 等数字货币数据存储 5 美国国会图书馆,历史资料永久保存在 IPFS 6 加
2021-06-01 09:31:24
开拓者的车机是兼容苹果和<em>安卓</em>,虽然我不怎么用,但确实兼顾了我家人的很多需求:副驾的门板还配有解锁开关,有的时候老婆开车,下车的时候偶尔会忘记解锁,我在副驾驶可以自己开门:第二排设计很好,不仅配置了一个很大的
2021-06-01 09:30:48
不仅是<em>安卓</em>手机,苹果手机的降价力度也是前所未有了,iPhone12也“跳水价”了,发布价是6799元,如今已经跌至5308元,降价幅度超过1400元,最新定价确认了。iPhone12是苹果首款5G手机,同时也是全球首款5nm芯片的智能机,它
2021-06-01 09:30:45