50道SQL练习题(navicat)(部分)

这是一组SQL练习题,涵盖了多种查询场景,包括查询特定课程情况、学生选课统计、教师信息、课程成绩分析、及格率计算等,旨在提升SQL操作技能。
摘要由CSDN通过智能技术生成

1.1 查询同时存在" 01 “课程和” 02 "课程的情况

select t1.*,t2.CId ,t2.Score 
from (select sc.* from sc where sc.CId='01') as t1,
(select sc.* from sc where sc.CId='02' ) as t2 
where t1.SId = t2.SId and t1.SId

1.2 查询存在" 01 “课程但可能不存在” 02 "课程的情况(不存在时显示为 null )

select * from (select * from sc where sc.CId='01') as t1 
left join (select * from sc where sc.CId='02')as t2 on t1.SId =t2.SId

4.查询所有同学的学生编号、学生姓名、选课总数、所有课程的总成绩(没成绩的显示为null)

select student.SId,student.Sname,t1.countCId,t1.sumScore 
from student,(select sc.SId,count(sc.CId)as countCId ,sum(sc.Score)as sumScore 
from sc group by SId  )as t1 where student.SId=t1.SId
  1. 查询「李」姓老师的数量
select count(*) from teacher where Tname like '%李%'
  1. 查询学过「张三」老师授课的同学的信息
select student.* from stude
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值