版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 高中化学练习题基础课时7 氧化还原反应方程式的配平与计算
- 华豫佰佳配送效率提升
- 阑尾炎的护理案例分析
- 作物表型组学 课件 第9-15章 种子表型分析技术-表型与作物遗传育种结合
- 福建幼儿师范高等专科学校《局域网组建、管理与维护》2025-2026学年期末试卷
- 中国矿业大学《科学技术与社会》2025-2026学年期末试卷
- 宣化科技职业学院《计量经济学题库》2025-2026学年期末试卷
- 安徽黄梅戏艺术职业学院《犯罪心理学》2025-2026学年期末试卷
- 阳光学院《口腔黏膜病学》2025-2026学年期末试卷
- 长春工业大学《教学系统设计》2025-2026学年期末试卷
- 【喀什】2025下半年新疆喀什技师学院面向社会公开引进急需紧缺人才23人笔试历年典型考题及考点剖析附带答案详解
- 初中地理七年级下册《热力巴西-自然基底与人文脉动探究》教案
- 中央民族大学辅导员考试题库
- 福建省集成电路产业园区控制性详细规划设计
- 《闭水试验excel自动计算表》化学建材管和钢筋混凝土管 管道内径 允许渗水量 试验段上游设计水头
- 抖音直播新人培训学习完整手册
- LY/T 3253-2021林业碳汇计量监测术语
- GB/T 40545-2021煤层气井压裂作业导则
- GB/T 17587.3-2017滚珠丝杠副第3部分:验收条件和验收检验
- GB/T 12616.1-2004封闭型沉头抽芯铆钉11级
- 铝用预焙阳极生产简介课件
评论
0/150
提交评论