打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
SQL简单查询

1、查询教师所有的单位即不重复的Depart列

select distinct depart from teacher

2、查询Score表中成绩在60到80之间的所有记录

select * from score where degree between 60 and 80

3、查询Score表中成绩为85,86或88的记录

select * from score where degree in (85,86,88)

4、查询Student表中“95031”班或性别为“女”的同学记录

select * from student where class='95031' or ssex ='女'

5、以Cno升序、Degree降序查询Score表的所有记录

select * from score order by cno,degree desc

6、查询“95031”班的学生人数

select count(*) from student where class='95031'

或者:select count(*) as scount from student where class='95031'  

---查询结果另取列名 为scount 展示

7、查询Score表中的最高分的学生学号和课程号

select sno,cno from score where degree=(select max(degree) from score) 

8、查询每门课的平均成绩

select cno,avg(degree) from score group by cno

9、查询Score表中至少有5名学生选修的并以3开头的课程的平均分数

select cno,avg(degree) from score group by cno having count(*)>=5 and cno like'3%'

10、查询所有学生的Sname、Cno和Degree列

select sname,cno,degree from student,score

where student.sno=score.sno

或者:select sname,cno,degree from score join student on score.sno = student.sno

11、查询所有学生的Sname、Cname和Degree列

select sname,cname,degree from student,course,score where student.sno = score.sno and score.cno=course.cno

或者:select sname,cname,degree from score join student on student.sno=score.sno join course on score.cno = course.cno

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
数据库
经典SQL练习题
数据库的简单查询和链接查询
数据库笔试题
通过16道练习学习Linq和Lambda
一套Oracle SQL练习题及答案
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服