版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 复杂查询实验报告江培健 101404215 10计教(2)班(1) 查找有销售记录的客户编号、名称和订单总额。select a.customerno,customername, sum(quantity*price) ordersumfrom ordermaster a,orderdetail b,customer cwhere b.orderno=a.orderno and c.customerno=a.customerno group by a.customerno,customernameorder by a.customerno,ordersum desc(2) 在订单明细表中查询订
2、单金额最高的订单(3) select top 1 orderno,sum(quantity*price)订单金额from orderdetailgroup by ordernoorder by 订单金额 desc3查询没有订购商品的客户编号和客户名称select customerno,customernamefrom customer where customerno not in (select customerno from ordermaster)(4) (4) 找出至少被订购3次的商品编号、订单编号、订货数量和订货金额,并按订货数量的降序排序输出。select productno ,o
3、rderno ,quantity ,quantity *price 订货金额from orderdetail where productno in(select productno from orderdetail group by productno having count(*)=3)order by productno desc (5) (5) 使用子查询查找16m dram的销售情况,要求显示相应的销售员的姓名、性别,销售日期、销售数量和金额(6)select employeename,case sex(7) when f then 女(8) when m then 男 end sex
4、,(9) orderdate,quantity,quantity*price 金额(10)from employee a,ordermaster b,orderdetail c(11)where a.employeeno=b.salerno and b.orderno=c.orderno(12) and c.productno in (13) select f.productno(14) from ordermaster d,orderdetail e,product f(15) where d.orderno=e.orderno and productname=32m dram)(6)(7)
5、 (6) 查询ordermaster表中订单金额最高的订单号及订单金额select orderno ,ordersum from ordermaster where ordersum =(select max(ordersum ) from ordermaster )(7) 计算出一共销售了几种商品select count(*)种类from (select distinct productno from orderdetail)a(8) 显示orderdetail表中每种商品的订购金额总和,并且依据销售金额由大到小排序输出。select productno ,sum(quantity *pri
6、ce ) 订购金额from orderdetail group by productno order by 订购金额 desc(9) 查找销售总额大于1000元的销售员编号、姓名和销售额select salerno,employeename,sum(ordersum)totalfrom ordermaster a,employee bwhere employeeno=salerno and ordersum1000group by salerno,employeename(10) 找出目前业绩未超过5000元的员工,并按销售业绩的降序排序输出select employeeno,employee
7、name,sumorderfrom (select employeeno,employeename from employee)x left join (select salerno,sum(sumorder) sumorder from (select salerno,sumorder=quantity*price from ordermaster a left outer join orderdetail b on a.orderno=b.orderno)m group by salerno)y on x.employeeno=y.salerno where sumorder(select
8、 avg(salary) avgsalary from employee where department=业务科 or department=财务科 or department=办公室)(12) 计算每一种商品的销售数量、平均销售单价和总销售金额select productno,sum(quantity)销售数量,avg(price)平均销售单价,sum(quantity*price)总销售金额from orderdetailgroup by productno(13) 查找至少有3次销售的业务员名单和销售日期select employeename,orderdatefrom orderma
9、ster a left join employee b on b.employeeno=a.salerno where salerno=(select salerno from ordermaster group by salerno having count(*)2)(14) 查询订单中所订购的商品数量没有超过10个的客户编号和客户名称select x.customerno,customernamefrom ordermaster x,customer ywhere x.customerno=y.customerno and orderno in (select orderno from orderdetail group by orderno having sum(quantity)40000order by sumorder desc一、 (17) 求出每位客户的总订购金额,显示出客户号及总订购金额,并按总订购金额降序排列。select x.customerno,sum(quantity*price)订购金额from customer x,(select a.orderno,quantity,price,customerno from orderdetail a left join ordermaster b on a.orderno
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- GB/T 13177-2026核电厂优先电源
- 2025年无锡市江阴市教育系统招聘笔试真题
- 2025年呼伦贝尔市额尔古纳市招聘专职消防救援队员笔试真题
- 主体结构施工方案难点(3篇)
- 设备监理师《设备监理验收标准》专项练习(完整版)
- 小学思想政治理论课情况调研报告2026(3篇)
- 2026年山西小升初数学考试(真题)及参考答案
- 2026年青海小升初(英语)考试试卷(真题)(含答案)
- 2026年山西(专升本)护理学真题试卷附答案
- 2026年山东中考数学真题(含答案)
- GB/T 46356-2025公共安全视频图像共享交换平台技术要求
- 畜牧统计培训课件
- Unit 3 第4课时Fuel up教学设计
- 美食表演秀创新创业项目商业计划书
- 2025年山东省公务员录用考试《行测》真题及答案
- 乡镇医院标准化建设课件
- GA/T 2183-2024法庭科学足迹检验实验室建设规范
- 2024年度移动通信基站维护服务合同范本3篇
- 建筑中级职称《建筑电气工程》历年考试真题题库(含答案)
- 医院培训课件:《静脉血栓栓塞症(VTE)专题培训》
- T-CI 263-2024 水上装配式钢结构栈桥(平台)施工技术规程
评论
0/150
提交评论