版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- N-Acylmannosamine-1-Dehydrogenase-Pseudomonas-sp-生命科学试剂-MCE
- 食堂安全培训计划幼儿
- 高中化学实验探究无机物沉淀反应原理记录训练试卷及答案
- 初中物理实验观察力学实验功和能转化关系实验设计训练试题及答案
- 2026年房车营地管理员(技师)职业技能等级认定历年真题
- 蓝色简约会议活动流程表
- 家长会制作课件
- 2026年浙江杭州市名校共同体6月中考二模英语试卷
- 2026年江苏常熟昆承中学集团校中考考前阶段性阳光测评英语
- 浙江省嘉兴八校2026-2027学年高二上学期11月期中考试生物试卷
- 2026璧山区第二批面向社会公开招聘社区工作者(网格治理岗)后备人选350人考试参考试题及答案解析
- 【海上风电运维】深远海风电场无人化智慧运维平台系统设计方案
- 护理动漫模板课件
- 外研版八年级上册Unit4 Digital life单元测试卷(含参考答案)
- 2026危险化学品行业安全隐患排查对标手册
- 康复医学科常见功能障碍康复指南(2026版)
- 2026年国家药品监督管理局药品和医疗器械审评检查华中分中心编外招聘35人考试备考试题及答案解析
- 2026秋小学人教版数学五年级上册《四 图形的运动 》易错题专项练习含参考答案
- 2026年场厂内专用机动车辆安全试题带答案
- T/CAR 24-2025数据中心泵驱两相冷板式液冷系统技术规范
- 消化内科质控实施方案与年度计划
评论
0/150
提交评论