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

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

ID:6089134

大小:2.11 MB

页数:8页

时间:2018-01-02

实验五-复杂查询-实验报告_第1页
实验五-复杂查询-实验报告_第2页
实验五-复杂查询-实验报告_第3页
实验五-复杂查询-实验报告_第4页
实验五-复杂查询-实验报告_第5页
资源描述:

《实验五-复杂查询-实验报告》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、实验五复杂查询1实验目的与要求(1)熟练掌握SQL语句的使用。(2)熟练使用SQL语句进行连接操作。2实验内容(1)在订单明细表中查询订单金额最高的订单。selecta.*fromorderdetaila,ordermasterbwherea.orderno=b.ordernoandordersum=(selectmax(ordersum)fromordermaster)(2)找出至少被订购3次的商品编号、订单编号、订货数量和订货金额,并按订货数量的降序排序输出。selectproductno商品编号,orderno订单编号,quantity订货数量,qua

2、ntity*price订货金额fromorderdetailwhereproductnoin(selectproductnofromorderdetailgroupbyproductnohavingcount(*)>=3)orderbyquantitydesc8(1)查找销售总额少于5000元的销售员编号、姓名和销售额。selecta.salerno销售员编号,b.employeename姓名,sum(ordersum)销售额fromordermastera,employeebwherea.salerno=b.employeenogroupbya.saler

3、no,b.employeenamehavingsum(ordersum)<5000(2)找出目前业绩未超过5000元的员工,并按销售业绩的降序排序输出。selectsalerno销售员编号,sum(ordersum)销售业绩fromordermastergroupbysalernohavingsum(ordersum)<=5000orderbysum(ordersum)desc(3)查询订购的商品数量没有超过10个的客户编号和客户名称。selecta.customerno客户编号,customername客户名称fromcustomera,ordermast

4、erb,orderdetailcwherea.customerno=b.customernoandb.orderno=c.ordernogroupbya.customerno,customernamehavingsum(quantity)<=108(1)查找订货金额最大的客户名称和总货款。selectcustomerno客户名称,sum(ordersum)总货款fromordermastergroupbycustomernohavingsum(ordersum)=(selectmax(sumorder)from(selectcustomerno,sum(or

5、dersum)assumorderfromordermastergroupbycustomerno)b)(2)查找至少订购了3种商品的客户编号、客户名称、商品编号、商品名称、数量和金额。selecta.customerno客户编号,customername客户名称,b.productno商品编号,productname商品名称,quantity数量,quantity*price金额fromcustomera,productb,ordermasterc,orderdetaildwherea.customerno=c.customernoandb.product

6、no=d.productnoandc.orderno=d.ordernoandd.ordernoin(selectordernofromorderdetailgroupbyordernohavingcount(productno)>=3)orderbya.customerno8(1)找出目前销售业绩超过4000元的业务员编号及销售业绩,并按销售业绩从大到小排序。selectsalerno销售员编号,sum(ordersum)销售业绩fromordermastergroupbysalernohavingsum(ordersum)>4000orderbysum(

7、ordersum)desc(2)求每位客户订购的每种商品的总数量及平均单价,并按客户号、商品号从小到大排列。selectcustomerno客户编号,productno商品编号,sum(quantity)总数量,avg(price)平均单价fromordermastera,orderdetailbwherea.orderno=b.ordernogroupbycustomerno,productnoorderbycustomerno,productno(3)查询业绩最好的的业务员号、业务员名及其总销售金额。selectsalerno业务员号,employeen

8、ame业务员名,sum(ordersum)销售金额f

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。