实验五-复杂查询-实验报告.docxVIP

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
实验五-复杂查询-实验报告

实验五 复杂查询1实验目的与要求(1) 熟练掌握SQL语句的使用。(2) 熟练使用SQL语句进行连接操作。2 实验内容在订单明细表中查询订单金额最高的订单。select a.*from orderdetail a,ordermaster bwhere a.orderno=b.orderno and ordersum=(selectmax(ordersum)from ordermaster)找出至少被订购3次的商品编号、订单编号、订货数量和订货金额,并按订货数量的降序排序输出。select productno 商品编号,orderno 订单编号,quantity 订货数量,quantity*price 订货金额from orderdetailwhere productno in(select productnofrom orderdetailgroupby productno havingcount(*)=3)orderby quantity desc查找销售总额少于5000元的销售员编号、姓名和销售额。select a.salerno 销售员编号,b.employeename 姓名,sum(ordersum)销售额from ordermaster a,employee bwhere a.salerno=b.employeenogroupby a.salerno,b.employeenamehavingsum(ordersum)5000找出目前业绩未超过5000元的员工,并按销售业绩的降序排序输出。select salerno 销售员编号,sum(ordersum)销售业绩from ordermastergroupby salernohavingsum(ordersum)=5000orderbysum(ordersum)desc查询订购的商品数量没有超过10个的客户编号和客户名称。select a.customerno 客户编号,customername 客户名称from customer a,ordermaster b,orderdetail cwhere a.customerno=b.customerno and b.orderno=c.ordernogroupby a.customerno,customernamehavingsum(quantity)=10查找订货金额最大的客户名称和总货款。select customerno 客户名称,sum(ordersum)总货款from ordermastergroupby customernohavingsum(ordersum)=(selectmax(sumorder)from(select customerno,sum(ordersum)as sumorderfrom ordermastergroupby customerno)b)查找至少订购了3种商品的客户编号、客户名称、商品编号、商品名称、数量和金额。select a.customerno 客户编号,customername 客户名称,b.productno 商品编号,productname 商品名称,quantity 数量,quantity*price 金额from customer a,product b,ordermaster c,orderdetail dwhere a.customerno=c.customerno and b.productno=d.productno and c.orderno=d.ordernoand d.orderno in(select orderno from orderdetailgroupby ordernohavingcount(productno)=3)orderby a.customerno找出目前销售业绩超过4000元的业务员编号及销售业绩,并按销售业绩从大到小排序。select salerno 销售员编号,sum(ordersum)销售业绩from ordermastergroupby salernohavingsum(ordersum)4000orderbysum(ordersum)desc求每位客户订购的每种商品的总数量及平均单价,并按客户号、商品号从小到大排列。select customerno 客户编号,productno 商品编号,sum(quantity)总数量,avg(price)平均单价from ordermaster a,orderdetail bwhere a.orderno=b.ordernogroupby customerno,productnoorderby customerno,productno查询业绩最好的的业务员号、业务员名及其总销售金

文档评论(0)

xcs88858 + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档