暂无图片
暂无图片
暂无图片
暂无图片
暂无图片
数据库SQL.txt
105
6页
0次
2022-08-05
免费下载
sql 实例
1001 查询全体男同学信息情况
select * from student where sex=''
1002 查询选修了 1 号课的学生的学号和成绩
select sno,grade from sc where cno='1'
1003 查询 1989 年以前出生的学生学号和姓名和出生日期(提示请用 year(csrq)函数来取出生年
号再与 1989 比较)
select sno,sname,csrq from student where year(csrq)<1989
1004 查询信息系所有女生的学号,姓名,及所在系
select sno,sname,sdept from student where sdept='信息系' and sex='&
#39;
1005 查询课程名是数据库的课程号和学分
select cno,ccredit from course where cname='数据库'
1006 查询先行课号为 5 的课程号和课程名
select cno,cname from course where cpno='5'
1007 查询英语系 90 后的学生情况( 90 年后出生的)
select * from student where sdept='英语系' and year(csrq)>=1990
1008 查询计算机系或信息系中年龄超过 21 岁的同学情况.(设当前年为 2010 ,提示用当前年减去
出生年再与 21 岁比较)
select * from student where (sdept='计算机系' or sdept='信息系')
and (2010-year(csrq))>21
1009 请将 3 号课及 4 号课学生的学号课程号及成绩显示出来
select sno,cno,grade from sc where cno='3' or cno='4'
1010 查询所有先行课程号为 0 且学分为 2 的课程名,先行课程号,及学分
select cname,cpno,ccredit from course where cpno='0' and ccredit=2
2010 查询学分为 3 以上(不含 3),且课程名中包含着'数据'二字的所有课程名及学分
select cname ,ccredit from course where ccredit>3 and cname like '
%'
2001 查询年龄在 20-23 岁之间(含 20 23 岁)的学生姓名,系别,年龄(请不要用 between
句提交当前年 2010
select sname,sdept,(2010-year(csrq)) as age from student where (2010-
year(csrq))>=20 and (2010-year(csrq))<=23
2002 查询选修过课程的所有学生的学号(不许重复)
select distinct sno from sc
2003 请将选修了课程的同学按课程号升序,成绩降序排序
select * from sc order by cno,grade desc
2004 请将选了 1 号课程的同学按成绩降序排序
select * from sc where cno='1' order by grade desc
2005 查询选修了 1 号课的成绩大于 85 分的学号和成绩
select sno,grade from sc where cno='1' and grade>85
2006 查询所有李姓同学情况
select * from student where sname like '%'
2007 查询所有两字姓名的张姓同学的姓名,性别与系别
select sname,sex,sdept from student where sname like '_'
2008 查询名字中第 3 个字为铃的学生的姓名和学号
select sname,sno from student where sname like '__'
2009 查询信息系所
有不姓刘的同学的学号和姓名
select sno,sname from student where sdept ='信息系' and sname not like
'%'
3001 查询所有选修过课的学生的姓名,课程名及成绩
select sname,cname,grade
from student,sc,course
where student.sno=sc.sno and sc.cno=course.cno and (cname='数据库' or
cname='信息系统')
3002 查询选修了 1 号课且成绩大于 80 分的的同学的姓名,课程号及成绩
select sname,cno,grade
from student,sc
where student.sno=sc.sno and cno='1' and grade>80
3003 查询没有选 1 号课的女生姓名,课程号及成绩,并将成绩按降序排序
select sname,cno,grade
from student,sc
where student.sno=sc.sno and not (cno='1') and sex='' order
by grade desc
3004 查询选修了数据库课的所有男生的姓名及该课的成绩
of 6
免费下载
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文档的来源(墨天轮),文档链接,文档作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

关注
最新上传
暂无内容,敬请期待...
下载排行榜
Top250 周榜 月榜