实验五_复杂查询答案{2012.4}
-------------------------------------------------------------------------------------------------------
(1)用子查询查询员工“张小娟”所做的订单信息。(难易程度:易)
select * from ordermaster
where salerno in
(
select employeeno from employee where employeename=张小娟
)
------------------------------------------------------------------------------------------------
(2)查询没有订购商品的且在北京地区的客户编号,客户名称和邮政编码,并按邮政编码降序排序。(难易程度:易)
select customerno,customername,zip
from customer c
where address=北京市 and not exists
(select * from ordermaster o where c.customerno=o.customerno)
order by zip desc
方法二:
select CustomerNo,CustomerName,Zip
from Customer
where Address=北京市 and CustomerNo not in (select CustomerNo
from OrderMaster )
order by Zip desc
-----------------------------------------------------------------------------------------------------------------
(3)查询订购了“32M DRAM”商品的订单编号,订货数量和订货单价。
(难易程度:易)
select orderno,quantity,price from orderdetail where productno in
(
select productno from product where productname=32M DRAM
)
-------------------------------------------------------------------------------------------------------------------
(4)查询与员工编号“E2008005”在同一个部门的员工编号,姓名,性别,所属部门。
(难易程度:易)
select employeeno,employeename,sex,department from employee
where department in
(
select department from employee where employeeno =E2008005
)
and employeeno !=E2008005
-------------------------------------------------------------------------------------------------------------------
(5)查询既订购了品,又订购了品的客户编号,订单编号和订单金额。 (难易程度:中)
(为了验证查询结果,改为:‘P2005001’和 ‘P2005002’)
方法一:
select customerno,orderno,ordersum from ordermaster
where orderno in
(
select orderno from orderdetail where productno = P2005001
)
and orderno in
(
select orderno from orderdetail where productno = P2005002
)
方法二:可以使用表的自身连接。
Select customerno, orderno, ordersum
from ordermaster
where orderno in
(
select a.orderno from orderdetail a,orderdetail b
where a.productno=P2005001 and b.productno=P2005002 and a.or
您可能关注的文档
- 实验一一一火山喷发.ppt
- 实验一锯齿波同步移相触发电路和单相桥式半控整流电路实验.ppt
- 实验七 图像增强—平滑和滤波.docx
- 实验七——线程同步和多线程编程.docx
- 实验七 全差分运放仿真方法.ppt
- 实验七 微生物分离、培养和菌种保藏.ppt
- 实验七:血清铁及总铁结合 一 副本.ppt
- 实验三 灰度变换和直方图处理.doc
- 实验三 CorelDraw线编辑和造形工具使用.ppt
- 实验三 气压、风观测观测.ppt
- 小区绿化施工协议书.docx
- 墙面施工协议书.docx
- 1 古诗二首(课件)--2025-2026学年统编版语文二年级下册.pptx
- (2026春新版)部编版八年级道德与法治下册《3.1《公民基本权利》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《4.3《依法履行义务》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《6.2《按劳分配为主体、多种分配方式并存》PPT课件.pptx
- (2026春新版)部编版八年级道德与法治下册《6.1《公有制为主体、多种所有制经济共同发展》PPT课件.pptx
- 初三教学管理交流发言稿.docx
- 小学生课外阅读总结.docx
- 餐饮门店夜经济运营的社会责任报告(夜间贡献)撰写流程试题库及答案.doc
最近下载
- 【花生十三】25公务员考试资料分析速算练习册及速算过程.pdf VIP
- mst2016说明书.pdf VIP
- 口腔科课件洁治.pptx
- 2025兴安盟公安局招聘165名留置看护警务辅助人员备考试题及答案解析.docx VIP
- 35KV变电站毕业设计(完整版).doc VIP
- AP微观经济学 2012年真题 (选择题+问答题) AP Microeconomics 2012 Released Exam and Answers (MCQ+FRQ).pdf VIP
- 上海师范大学天华学院公共课《大学计算机基础》期末试卷A(有答案).docx VIP
- 高中生对AI 技术应用的态度与认知调查问卷.docx VIP
- 2025年度”五个方面“专题组织生活会个人对照检查发言材料.docx VIP
- 南方医科大学各专业实习大纲汇编.pdf VIP
原创力文档

文档评论(0)