- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
(实例学习SQL的Select命令
实例学习SQL的Select命令
1、查找员工的编号、姓名、部门和出生日期,如果出生日期为空值,--显示日期不详,并按部门排序输出,日期格式为yyyy-mm-dd。select emp_no ,emp_name ,dept ,isnull(convert(char(10),birthday,120),日期不详) birthdayfrom employeeorder by dept --2、查找与喻自强在同一个单位的员工姓名、性别、部门和职称select emp_no,emp_name,dept,titlefrom employeewhere emp_name喻自强 and dept in(select dept from employeewhere emp_name=喻自强)--3、按部门进行汇总,统计每个部门的总工资select dept,sum(salary)from employeegroup by dept--4、查找商品名称为14寸显示器商品的销售情况,--显示该商品的编号、销售数量、单价和金额select a.prod_id,qty,unit_price,unit_price*qty totpricefrom sale_item a,product bwhere a.prod_id=b.prod_id and prod_name=14寸显示器--5、在销售明细表中按产品编号进行汇总,统计每种产品的销售数量和金额select prod_id,sum(qty) totqty,sum(qty*unit_price) totpricefrom sale_itemgroup by prod_id--6、使用convert函数按客户编号统计每个客户1996年的订单总金额select cust_id,sum(tot_amt) totpricefrom saleswhere convert(char(4),order_date,120)=1996group by cust_id--7、查找有销售记录的客户编号、名称和订单总额select a.cust_id,cust_name,sum(tot_amt) totpricefrom customer a,sales bwhere a.cust_id=b.cust_idgroup by a.cust_id,cust_name--8、查找在1997年中有销售记录的客户编号、名称和订单总额select a.cust_id,cust_name,sum(tot_amt) totpricefrom customer a,sales bwhere a.cust_id=b.cust_id and convert(char(4),order_date,120)=1997group by a.cust_id,cust_name--9、查找一次销售最大的销售记录select order_no,cust_id,sale_id,tot_amtfrom saleswhere tot_amt=(select max(tot_amt)from sales)--10、查找至少有3次销售的业务员名单和销售日期select emp_name,order_datefrom employee a,sales b where emp_no=sale_id and a.emp_no in(select sale_idfrom salesgroup by sale_idhaving count(*)=3)order by emp_name--11、用存在量词查找没有订货记录的客户名称select cust_namefrom customer awhere not exists(select *from sales bwhere a.cust_id=b.cust_id)--12、使用左外连接查找每个客户的客户编号、名称、订货日期、订单金额--订货日期不要显示时间,日期格式为yyyy-mm-dd--按客户编号排序,同一客户再按订单降序排序输出select a.cust_id,cust_name,convert(char(10),order_date,120),tot_amtfrom customer a left outer join sales b on a.cust_id=b.cust_idorder by a.cust_id,tot_amt desc--13、查找16M DRAM的销售情况,要求显示相应的销售员的姓名、--性别,销售日期、销售数量和金额,其中性别用男、女
您可能关注的文档
最近下载
- (正式版)SH∕T 3553-2024 石油化工汽轮机施工及验收规范.pdf VIP
- 电气专项施工方案.doc VIP
- 个人简历——【标准模板】.doc VIP
- 软件开发工具unsp ide使用说明书.pdf VIP
- 【课堂新坐标(教师用书)高中英语 Unit 3 Period V Culture Corner & Bulletin Board课件 北师大版必修1.ppt VIP
- 老年病多学科诊疗模式.pptx VIP
- GPX 生产手册.pdf VIP
- 老年病多学科诊疗模式.pptx VIP
- 【课堂新坐标(教师用书)高中英语 Unit 1 Lifestyles单元归纳提升课件 北师大版必修1.ppt VIP
- 新课标高中英语 教师用书配套资料 Unit1~2 阶段综合检测 北师大版必修1.doc VIP
文档评论(0)