查询计算机基础课不及格的学生名单,SQL-select语句练习

1、查询各系教师和学生人数

2、查询学生的选课情况(学生只能选修所在系的教师课程)

3、统计各系各职称教师的最高最低和平均工资

4、查询学生中年龄最小的前三名学生

5、查询各系姓“王”学生的分布情况

6、查询学生中重名的名字,并统计同名的学生人数

7、查询教师中总收入排行前3的教师信息

8、统计每门课程的学生选修人数。要求输出人数超过10人的课程号和选修人数, 查询结果按人数降序排列,若人数相同,按课程号升序排列。

9、查询选修了“计算机基础”而没选修“微机原理”的学生名单

10、查询没有选全部课程的学生名单

11、查询选修了“张雪”教师课程中分数最高的学生选课情况

12、查询每门课程考试成绩最好的同学学号和姓名

13、统计有两门课程不及格的学生学号及其平均成绩

14、把成绩低于该课程平均成绩的女生分数提高5分

15、查询未选修任何课程的学生名单

解析:

use jiaoxuedb

/*1*/select teacher.dept,count(distinct sno) 学生,count(distinct tno) 教师 from teacher,student

where teacher.dept=student.dept group by teacher.dept

/*2*/select sn,cn,score from student,sc,course,tc,teacher where student.sno=sc.sno and http://doc.xuehai.neto=http://doc.xuehai.neto and http://doc.xuehai.neto=http://doc.xuehai.neto and tc.tno=teacher.tno

/*3*/select dept,prof,max(sal) 最高,min(sal) 最低,avg(sal) 平均 from teacher group by dept,prof

/*4*/select top 3 * from student order by age desc

/*5*/select dept,count(sno) from student where sn like '王%'group by dept

/*6*/select sn,count(sno) from student group by sn having count(sno)>1 /*7*/select * from teacher where tno in(select top 3 tno from teacher order by sal+comm desc)

/*8*/select cno,count(sno) from sc group by cno having count(sno)>=10 order by count(sno) desc,cno asc

/*9*/select sno from sc where sno in (select sno from sc,course where http://doc.xuehai.neto=http://doc.xuehai.neto and cn='计算机基础')and sno not in

(select sno from sc,course where http://doc.xuehai.neto=http://doc.xuehai.neto and cn='微机原理') /*10*/select sn from student where sno in(select sno from sc group by sno having

count(cno)<>(select count(cno) from course ))

/*11*/select top 1 sc.sno from sc,teacher,tc,course,student where teacher.tno=tc.tno and http://doc.xuehai.neto=http://doc.xuehai.neto and http://doc.xuehai.neto=http://doc.xuehai.neto and

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值