上机练习3 - 数据查询(2)
17.
select 所在系,count(*) 学生总数,avg(成绩) 平均成绩 from student st join sc on st.学号=sc,学号 group by 所在系
18.
select 学号,count(课程号) 选课门数,avg(成绩) 平均成绩 from sc group by 学号 having count(课程号)>2
19.
select 学号,sum(成绩) 总成绩 from sc group by 学号 having sum(成绩)>200 20.
use pubs
select type ,avg(price) 平均价格,max(price) 最高价格
from titles group by type having avg(price)>12.0
21.
select avg(price) 平均价格 from titles where royalty=10 group by type 22.
select sum(price) 总价格 from titles group by type having count(type)>3 23.
use sqllx
select 姓名,所在系 from student st,sc where st.学号=sc.学号 and sc.课程号='c02'
24.
select 姓名,课程号,成绩 from student st,sc where st.学号=sc.学号 and sc.成绩>80
order by 成绩 desc
25.
select 姓名,性别,成绩 from student st , course co,sc where st.学号=sc.学号 and
sc.课程号=co.课程号 and st.所在系='计算机系'and co.课程名='数据库基础' and st.性别='男'
26.
select student.学号,姓名,课程号,成绩 from student left join sc on student.学号=sc.学号 27.
select top 3 st.学号,姓名,所在系,成绩 from student st,course co ,sc
where st.学号=sc.学号 and co.课程号=sc.课程号 and 课程名='数据库基础' order by 成绩 desc 28.
select distinct s1.学号, s1.课程号 from sc s1 join sc s2 on s1.课程号=s2.课程号 order by s1.课程号
29.
select distinct s1.姓名,s1.年龄 from student s1 join student s2 on s1.年龄=s2.年龄 order by s1.年龄
30.
select co.课程号,co.课程名 from course co , sc
where co.课程号=sc.课程号 and co.课程号 not in(select 课程号 from sc) 31.
select 姓名 student_name,课程名 course_name,成绩 grade into new_sc
from student st join sc on st.学号=sc.学号 join course co on co.课程号=sc.课程号 where sc.成绩 is not null
32.
select st.所在系,st.姓名,st.性别,co.课程名,sc.成绩 from student st,course co,sc where sc. 学号=st.学号 and sc.课程号=co.课程号 and st.所在系='计算机系' union
select st.所在系,st.姓名,st.性别,co.课程名,sc.成绩 from student st,course co,sc where sc. 学号=st.学号 and sc.课程号=co.课程号 and st.所在系='信息系'
33.
select distinct city from Employees union
select distinct city from Customers order by city asc 34.
select ProductID, ProductName, case
when UnitPrice <=10 then '很便宜'
when UnitPrice >10 and UnitPrice<=20 then '较便宜' when UnitPrice >20 and UnitPrice<=30 then '中等' when UnitPrice >30 and UnitPrice<=40 then '较贵' when UnitPrice >40 and UnitPrice<=100 then '很贵' when UnitPrice >100 then '价格过高' end
from products
where UnitsInStock>10 35.
select s.sno 学号,sname 姓名, case sdept
when '计算机系' then 'CS' when '信息系' then 'IS' when '数学系' then 'MA' else 'OTHER'
end 所在系,grade 成绩
from student s join sc on s.sno = sc.sno join course c on sc.cno=c.cno where cname='vb'
参考以上代码进行调试,发现错误并处理。
…… 此处隐藏:355字,全部文档内容请下载后查看。喜欢就下载吧 ……相关推荐:
- [基础教育]2016-2022年中国钢芯铝绞线市场现状调
- [基础教育]语文部编版初一语文下册练习题 句式变
- [基础教育]南京继续教育参考答案--深入学习贯彻习
- [基础教育]国旗下讲话稿——珍惜时间好读书
- [基础教育]北师大版六年级数学下册圆锥的体积教学
- [基础教育]人教版-音乐-四年级下册-四年级下册音
- [基础教育]乔布斯2019年斯坦福大学毕业典礼致辞.d
- [基础教育]2015年加油站安全知识竞赛试题及答案
- [基础教育]2020年教师年度考核个人工作总结
- [基础教育]2019年中考历史试题-2019年大庆市初中
- [基础教育]初三仁爱英语第一轮总复习教案
- [基础教育]SG-A094电气配管安装工程隐蔽验收记录
- [基础教育]冀教版小学数学三年级下册第六单元教材
- [基础教育]青岛版(五制)小学科学二年级下册16《制
- [基础教育]2018-2019年初中科学初一中考真卷测试
- [基础教育]幼儿园大班期末简短评语精选
- [基础教育]2018云南临沧公务员考试申论技巧:这样
- [基础教育]学校食堂经营管理方案
- [基础教育]新中国砥砺奋进的七十年原文
- [基础教育]真空泵的选型及常用计算公式
- 高职田径课程教学现状与对策
- 全髋关节置换术在老年股骨颈骨折患者中
- 青人社厅函〔2016〕576号(附件)工资
- cp101-07砂子检验作业指导书 - secret
- 微观经济学 第八章 博弈论 习题
- 2014高考真题(词语运用)汇编及答案
- 2018年人教版七年级语文下册《第三单元
- 苏教版数学四年级上册第一单元试题 - M
- 四川大学新闻与传播考研2000-2010年真
- 浙江万里学院英语专业四年制本科教学计
- 最新2018马年事业祝福语-范文word版(2
- 最全模具行业术语英文翻译
- 皮亚杰的发展心理学理论
- 64篇高考情景式默写 练习题及答案
- 仿写(学生稿)
- 《SQL Server数据库技术》试卷A
- 第七章作业答案
- 江苏省赣榆县海头高级中学高中语文必修
- 浙江省2001年10月自考正常人体解剖学答
- 2012英语重点短语




