- 1、本文档共5页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
HW # 2 answers -.doc
HW # 2 answers -
1) List name and city of all customers. (Coffee: Projection)
Select cname, city from customers;
2) List products in descending order by price (Coffee: SQL - JavaApplets - Constructing SQL Queries advance - Order By)
Select * from products order by price desc;
3) List customers that ordered ‘p01’ or ‘p02’ (Coffee: Restriction)
Select cid from orders where pid = ‘p01’ or pid = ‘p02’
4) List customers that ordered ‘p01’ and ‘p02’ (Need to use INTERSECT or 2 Virtual tables of ORDERS).
Select * from customers where cid in (select cid from orders where pid = ‘p01’)
And cid in (select cid from orders where pid = ‘p02’);
5) List the name of each agent and the sum of orders (in dollars) that each agent ordered (Coffee: SQL - JavaApplets - Constructing SQL Queries advance - Functions and Group BY)
select a.aname, sum (dollars) Dollars
from agents a, orders o where a.aid = o.aid group by a.aname;
6) Insert a new row in customers with cid = ‘c007’, ‘Coke’, ‘Atlanta’, 7 (Coffee: SQL - JavaApplets - Data Definition Language and Data Manipulation Language)
Insert into customers (cid, cname, city, discnt) values (‘c007’, ‘Coke’, ‘Atlanta’, ‘7.00’);
7) List the name each customers and the total amount ordered by the customers
If the customers didn’t place an order, list them also.
Select c.cname, sum (o.dollars) Dollars
From customers c, orders o
Where c.cid = o.cid (+)
Group by cname;
8) List name of customers that ordered all the products.
Select cname from customers c where not exists
(Select * from products p where not exists
(select * from orders o where o.cid = c.cid and o.pid = p.pid));
9) List all pair of products that are in the same city (Coffee: SQL - More SQL (Visual Basic) - Join with 1 table
Select p1.pid, p2.pid
From products p1, products p2
Where p1.pid p2.pid and p1.city = p2.city;
List the three most expensive products (one sql statement. Warning: HARD. Use NOT EXISTS)
Select *
您可能关注的文档
- httpbaike.baidu.comview53598.htm.doc
- httpwww.ctaso.org.twdietmethod.html.doc
- httpwww.lvshou.comtopicguanghwsx.doc
- Human rights and reform of the.doc
- H套健康体检推荐项目(616元人).doc
- I485-16串口服务器快速安装指南.doc
- IBM ETP(无锡)实训基地.doc
- ICP(网站)安全责任告知书.doc
- IDC业务协议(托管).doc
- IDC业务协议(租用).doc
- 讲稿文案3rd angle projection 4 sc初步.pdf
- 社会化媒体优化.pdf
- sw6强度校核t0201英文版.pdf
- 2024有色金属矿业效能报告 -.pdf
- 新高考I卷读后续写David'sRun课件-高考英语作文复习专项.pptx
- 2.1《减数分裂与受精作用》(第二课时)课件高一下学期生物人教版必修2.pptx
- 重庆市第一中学高三下学期适应性考试最后一卷历史试题(原卷版).docx
- 10.5带电粒子在电场中的运动课件-高二上学期物理人教版.pptx
- 20222023学年高三上学期期中考试语文试卷(仿新高考1卷)(含试卷细目分析表)-2023年新高考语文一轮复习(统编版)原卷版.docx
- 空间点直线平面之间的位置关系(课件)-高一下学期数学人教A版.pptx
文档评论(0)