- 7
- 0
- 约9.64千字
- 约 16页
- 2016-12-07 发布于湖北
- 举报
1、查找员工的编号、姓名、部门和出生日期,如果出生日期为空值, --显示日期不详,并按部门排序输出,日期格式为yyyy-mm-dd。 select?emp_no?,emp_name?,dept?, isnull(convert(char(10),birthday,120),日期不详)?birthday from?employee order?by?dept? --2、查找与喻自强在同一个单位的员工姓名、性别、部门和职称 select?emp_no,emp_name,dept,title from?employee where?emp_name喻自强?and?dept?in (select?dept?from?employee where?emp_name=喻自强) --3、按部门进行汇总,统计每个部门的总工资 select?dept,sum(salary) from?employee group?by?dept --4、查找商品名称为14寸显示器商品的销售情况, --显示该商品的编号、销售数量、单价和金额 select?a.prod_id,qty,unit_price,unit_price*qty?totprice from?sale_item?a,product?b where?a.prod_id=b.prod_id?and?prod_name=14寸显示器 --5、在销售明细表中按产品编号进行汇总,统计每种产品的销售数量和金额 select?prod_id,sum(qty)?totqty,sum(qty*unit_price)?totprice from?sale_item group?by?prod_id --6、使用convert函数按客户编号统计每个客户1996年的订单总金额 select?cust_id,sum(tot_amt)?totprice from?sales where?convert(char(4),order_date,120)=1996 group?by?cust_id --7、查找有销售记录的客户编号、名称和订单总额 select?a.cust_id,cust_name,sum(tot_amt)?totprice from?customer?a,sales?b where?a.cust_id=b.cust_id group?by?a.cust_id,cust_name --8、查找在1997年中有销售记录的客户编号、名称和订单总额 select?a.cust_id,cust_name,sum(tot_amt)?totprice from?customer?a,sales?b where?a.cust_id=b.cust_id?and?convert(char(4),order_date,120)=1997 group?by?a.cust_id,cust_name --9、查找一次销售最大的销售记录 select?order_no,cust_id,sale_id,tot_amt from?sales where?tot_amt= (select?max(tot_amt) from?sales) --10、查找至少有3次销售的业务员名单和销售日期 select?emp_name,order_date from?employee?a,sales?b? where?emp_no=sale_id?and?a.emp_no?in (select?sale_id from?sales group?by?sale_id having?count(*)=3) order?by?emp_name --11、用存在量词查找没有订货记录的客户名称 select?cust_name from?customer?a where?not?exists (select?* from?sales?b where?a.cust_id=b.cust_id) --12、使用左外连接查找每个客户的客户编号、名称、订货日期、订单金额 --订货日期不要显示时间,日期格式为yyyy-mm-dd --按客户编号排序,同一客户再按订单降序排序输出 select?a.cust_id,cust_name,convert(char(10),order_date,120),tot_amt from?customer?a?left?outer?join?sales?b?on?a.cust_id=b.cust_id order?by?a.cust_id,tot_amt?desc --13、查找16M?D
您可能关注的文档
- 山东省2015年理综试题(解析版).doc
- 实验基本操作15.ppt
- 实验六 图的创建及应用(I).doc
- 山东省东营市2016届高三下学期第一次模拟考试 数学(理)(一模).doc
- 外国语 藤野先生课时1.pptx
- 实验5 电子表格软件.ppt
- 实验5_软工1302_2013011342_阮翀.doc
- 山东中运集团大棚用履带开沟机.pptx
- 实验6_迭代实现_物联1301班_刘悦_201308080112.docx
- 外科管道的观察及护理.pptx
- 小区绿化施工协议书.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
最近下载
- 2025年陕西省汉中市某中学小升初入学分班考试英语考试真题含答案.docx VIP
- DB31T 1236-2020 未成年人司法社会工作服务规范.docx VIP
- 宣贯培训(2026年)《DLT 2772—2024火力发电厂输煤廊道巡检装置技术规范》.pptx VIP
- 2026年北京中考白皮书.pdf VIP
- 2025届苏锡常镇高三(一模)数学试题及参考答案.pdf VIP
- 《人工智能辅助的翻译技术》课件.ppt VIP
- 沉浸式非遗体验—宋代点茶.pptx VIP
- PET Complete精品教学课件 unit 3 having fun.pptx
- 年产2万吨马铃薯全粉项目可行性研究报告.docx
- 《计算机网络基础》课件——OSI参考模型.pptx VIP
原创力文档

文档评论(0)