资源描述:
《数据库课外作业参考答案》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、第四章课外作业参考答案1、创建一个列表,显示每本书的书名以及出版社办公室中你再次订购每本书时需要与之联系的人的姓名和电话号码。1)SQL>selecttitle,contact,phone2frombooksb,publisherp3whereb.pubid=p.pubid;2)SQL>selecttitle,contact,phone2frombooksbjoinpublisherp3onb.pubid=p.pubid;2、确定哪些订单还没有发货以及下达各个订单的客户的姓名。将结果按下达订单的日期排序。1)SQL>selectorder#,lastname,fir
2、stname2fromorderso,customersc3whereo.customer#=c.customer#4andshipdateisnull5orderbyorderdate;2)SQL>selectorder#,lastname,firstname2fromordersojoincustomersc3ono.customer#=c.customer#4whereshipdateisnull5orderbyorderdate;3、列出已经购买了Fitness种类的图书的所有人的客户号和姓名。1)SQL>selectcustomers.customer#,
3、lastname,firstname2fromcustomers,books,orders,orderitems3wherebooks.isbn=orderitems.isbn4andorderitems.order#=orders.order#5andorders.customer#=customers.customer#6andcategory='FITNESS';2)SQL>selectcustomers.customer#,lastname,firstname2frombooksjoinorderitemsonbooks.isbn=orderitems.is
4、bn3joinordersonorderitems.order#=orders.order#4joincustomersonorders.customer#=customers.customer#5wherecategory='FITNESS';4、确定JakeLucas已经购买了哪些书。1)SQL>selecttitle2fromcustomers,books,orders,orderitems3wherebooks.isbn=orderitems.isbn4andorderitems.order#=orders.order#5andorders.customer
5、#=customers.customer#6andlastname='LUCAS'andfirstname='JAKE';2)SQL>selecttitle2frombooksjoinorderitemsonbooks.isbn=orderitems.isbn3joinordersonorderitems.order#=orders.order#4joincustomersonorders.customer#=customers.customer#5wherelastname='LUCAS'andfirstname='JAKE';5、确定销售给JakeLucas的每
6、一本书的利润。将结果按订单日期排序。如果订购了多本书,那么将结果按利润的降序排序。1)SQL>selectretail-cost2fromcustomers,books,orders,orderitems3wherebooks.isbn=orderitems.isbn4andorderitems.order#=orders.order#5andorders.customer#=customers.customer#6andlastname='LUCAS'andfirstname='JAKE'7orderbyorderdate,1desc;2)SQL>selectre
7、tail-cost2frombooksjoinorderitemsonbooks.isbn=orderitems.isbn3joinordersonorderitems.order#=orders.order#4joincustomersonorders.customer#=customers.customer#5wherelastname='LUCAS'andfirstname='JAKE'6orderbyorderdate,1desc;6、哪一本书是由姓氏为Adams的作者编写的?1)SQL>selecttitle2fromauthor,bookauthor