查询与维护学生信息管理数据表(分组与排序)

(1) 计算“C01”课程的平均成绩。

select count(distinct "cno") as "选课门数" from "sc";

 

(2) 统计有学生选修的课程的门数。

select avg("degree") from "sc";

 

(3)查询选修了“C03”课程的学生的学号及其成绩,查询结果按分数降序排列。

select "sno","degree" from "sc" where "cno"='c03' order by "degree" desc;

 

(4)查询各个课程号及相应的选课人数。

select "cno",count(*) as "选课人数" from "sc" group by "cno";

 

(5)统计每门课程的选课人数和最高分。

select "cno",count(*) as "选课人数",max("degree") as "最高分" from "sc" group by "cno","degree";

 

(6)统计每个学生的选课门数和考试总成绩,并按选课门数降序排列。

select "sno",count(*) as "选课门数",sum("degree") as "总成绩" from "sc" group by "sno" order by count(*) desc;

 

(7)查询选修了3门以上课程的学生学号。

select "sno",count(*) from "sc" group by "sno" having count(*)>3;

 

(8)查询成绩不及格的学生学号及课程号,并按成绩降序排列。

select "sno","cno","degree" from "sc" where "degree" <60 order by "degree" desc;

 

(9)查询至少选修一门课程的学生学号。

select "sno" from "sc" group by "sno" having count(*) >=1;

 

(10)统计输出各系学生的人数。

select "sdept",count(*) from "student_copy" group by "sdept";

 

(11)统计各系学生人数。

select "sdept",count(*) from "student_copy" group by "sdept";

 

(12)统计各系的男、女生人数。

select "sdept","ssex",count(*) as "人数" from "student_copy" group by "sdept","ssex";

 

(13)统计各班级的学生人数。

select "classno",count(*) "各班人数" from "student" group by "classno";

 

(14)统计各班的男、女生人数。

select "classno","ssex",count(*) from "student" group by "classno","ssex";

 

(15)统计各系的老师人数,并按人数降序排序。

select "deptno",count(*) as "老师人数" from "teacher" group by "deptno" order by count(*) desc;

 

(16)统计不及格人数超过10人的课程号。

select "cno" as "课程号",count(*) as "不及格人数" from "sc" group by "cno" having count(*) > 10;

 

(17)查询软件工程系的男生信息,查询结果按出生日期升序排序,出生日期相同的按地址降序排序。

select * from "student_copy" where "sdept" = '软件工程系' and "ssex" = '男' order by "sbirthday" asc,"saddress" desc;

  • 7
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值