mysql数据库技,Mysql数据库技术(四)

“001”课程比“002”课程成绩高的所有学生的学号;

select a.s_id from (select s_id,score from SC where C_ID=‘001‘) a,(select s_id,scorefrom SC where C_ID=‘002‘) b where a.score>b.score and a.s_id=b.s_id;

10.查询平均成绩大于60分的同学的学号和平均成绩;

select S_ID,avg(score) from sc group by S_ID having avg(score) >60;

11.查询所有同学的学号、姓名、选课数、总成绩;

select Student.S_ID,Student.Sname,count(SC.C_ID),sum(score) from Student left Outer join SC on Student.S_ID=SC.S_ID group by Student.S_ID,Sname

12.查询姓“李”的老师的个数;

select count(distinct(Tname)) from Teacher where Tname like ‘李%‘;

13.查询所有课程成绩小于60分的同学的学号、姓名;

select S_ID,Sname from Student where S_ID not in (select S.S_ID from Student AS S,SC where S.S_ID=SC.S_ID and score>60);

14.查询至少有一门课与学号为“1001”的同学所学相同的同学的学号和姓名;

select distinct S_ID,Sname from Student,SC where Student.S_ID=SC.S_ID and SC.C_ID in (select C_ID from SC where S_ID=‘1001‘);

Mysql数据库技术(四)

标签:技术   count   select   课程   mysql数据库   family   not   style   ike

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉

本文系统来源:https://www.cnblogs.com/husband/p/14229340.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值