云南大学软件学院数据库试验四实验4数据查询.docx
《云南大学软件学院数据库试验四实验4数据查询.docx》由会员分享,可在线阅读,更多相关《云南大学软件学院数据库试验四实验4数据查询.docx(16页珍藏版)》请在冰点文库上搜索。
云南大学软件学院数据库试验四实验4数据查询
云南大学软件学院实验报告
课程:
数据库原理与实用技术实验学期:
2013-2014学年第二学期任课教师:
薛岗、秦江龙
专业:
学号:
2012112****姓名:
成绩:
实验4数据查询
一、实验目的
1理解T-SQL语言的使用。
2熟练掌握数据查询语句。
3掌握合计函数的使用。
二、实验内容
1、CAP数据库的查询(记录每个查询的SQL语句和查询结果)
(1)建立CAP数据库,输入C、A、P、O四张表;
1.录入customers
2.录入表AGENTS
3.录入表ORDERS
4.录入表products
(2)完成课后习题[3.2]b、[3.5]、[3.8]a,b、[3.11]b,f,j,l
[3.2]b
[3.5]
另一种是
[3.8]a
b、
[3.11]b,
f,
J
另一种是:
l
2、Employee数据库的查询(记录每个查询的SQL语句和查询结果)
(1)向表中插入数据。
insertintosalaryvalues('000001','2100','500','1','2600');
insertintosalaryvalues('000002','3000','600','1','3600');
insertintosalaryvalues('000003','2800','450','1','3250');
insertintosalaryvalues('000004','2500','340','1','2840');
insertintosalaryvalues('000005','3200','490','1','3690');
insertintosalaryvalues('000006','2700','600','1','3300');
insertintosalaryvalues('000007','4000','200','1','4200');
insertintosalaryvalues('000008','2800','350','1','3150');
insertintosalaryvalues('000009','2760','440','1','3200');
insertintosalaryvalues('000001','2400','600','2','3000');
insertintosalaryvalues('000002','2800','400','2','3200');
insertintosalaryvalues('000003','2860','350','2','3210');
insertintosalaryvalues('000004','2540','320','2','2860');
insertintosalaryvalues('000005','3200','480','2','3680');
insertintosalaryvalues('000006','2700','300','2','3000');
insertintosalaryvalues('000007','4000','250','2','4250');
insertintosalaryvalues('000008','2800','300','2','3100');
insertintosalaryvalues('000009','2760','480','2','3240');
insertintosalaryvalues('000001','2200','500','3','2700');
insertintosalaryvalues('000002','3100','400','3','3500');
insertintosalaryvalues('000003','2800','650','3','3450');
insertintosalaryvalues('000004','2500','540','3','3050');
insertintosalaryvalues('000005','3200','400','3','3600');
insertintosalaryvalues('000006','2700','680','3','3380');
insertintosalaryvalues('000007','4100','400','3','4500');
insertintosalaryvalues('000008','2000','330','3','2330');
insertintosalaryvalues('000009','2760','420','3','3180');
select*fromsalary
insertintodepartmentvalues('001','营销部');
insertintodepartmentvalues('002','财务部');
insertintodepartmentvalues('003','人事部');
insertintodepartmentvalues('004','采购部');
select*fromdepartment
(2)将职工编号为000006的员工3月份基本工资增加为3000,奖金增加到800。
(3)员工000009已经离开公司,将该员工的数据删除
(4)简单条件查询
✓查询person表中所有不重复的职称。
✓
✓查询具有高级职称的女员工信息
✓
✓查询职工姓名为黎明的员工数据
因为之前我们已经将编号00009即黎明的信息都删除了,所以库里没有了关于他的记录
✓查询各部门的实发工资总数
✓
(5)复杂条件查询
✓查询平均工资高于3000的部门名和对应的平均工资。
✓
✓查询1月份实发工资比平均实发工资高的员工姓名和实发工资额。
✓查询2月份实发工资比一月高的员工姓名。
✓利用sql语句将1,2,3月累积的员工的实发工资按降序排序