admin 管理员组文章数量: 1087652
2024年4月17日发(作者:vuejs常用的事件修饰符)
word格式-可编辑-感谢下载支持
sql语句练习题1
数据库有如下四个表格:
student(sno,sname,sage,ssex,sdpt) 学生表
系表(dptno,dname)
course(cno,cname,
gradet,
tno) 课程表
sc(sno,cno,score) 成绩表
teacher(tno,tname) 教师表
要求:完成以下操作
1. 查询姓"欧阳"且全名为三个汉字的学生的姓名。
select sname from student where sname like “欧阳__‟;
2. 查询名字中第2个字为"阳"字的学生的姓名和学号。
select sname,sno from student where sname like '_阳%';
3. 查询所有不姓刘的学生姓名。
select sname,sno,ssex
from student
where sname not like “刘%”;
4. 查询db_design课程的课程号和学分。
select cno,ccredit from course
where cname like 'db_design'
5. 查询以"db_"开头,且倒数第3个字符为i的课程的详细情况。
select * from course where cname like 'db%i_ _';
6. 某些学生选修课程后没有参加考试,所以有选课记录,但没有考试成绩。查询缺少成绩
的学生的学号和相应的课程号。
select sno,cno from sc where grade is null;
word格式-可编辑-感谢下载支持
7. 查所有有成绩的学生学号和课程号。
select sno,cno from sc where grade is not null;
8. 查询计算机系年龄在20岁以下的学生姓名。
select sname from student where sdept= 'cs' and sage<20;
9. 查询选修了3号课程的学生的学号及其成绩,查询结果按分数降序排列。
select sno,grade from sc where cno= ' 3 ' order by grade
10. 查询学生总人数。
select count(*) from student;
11. 查询选修了课程的学生人数。
select count(distinct sno) from sc;
12. 计算1号课程的学生平均成绩。
select avg(grade) from sc where cno= ' 1 ';
13. 查询选修1号课程的学生最高分数。
select max(grade) from sc where cno= ' 1 ';
14. 查询学生200215012选修课程的总学分数。
select sum(grade) from sc,course
where sno= ' 200215012 ' and =;
15. 查询选修了3门以上课程的学生学号。
select sno from sc group by sno having count(*) >3;
16. 查询每个学生及其选修课程的情况。
desc;
版权声明:本文标题:SQL语句练习及答案 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1713354313a630544.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论