数据库期中复习题与部分答案.doc

  1. 1、本文档共14页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
数据库期中复习题与部分答案

1、查找表中所有姓刘的职工的工号,部门,薪水 selectemp_no,emp_name,dept,salary fromemployee whereemp_name like 刘% 2、查找所有定单金额高于20000的所有客户编号 selectcust_id from sales wheretot_amt20000 3、查找出职称为经理和职称为职员的女员工的姓名、职称、性别。 selectemp_name,title,sex fromemployee wheretitle=经理ortitle=职员and sex=F 4、选取销售数量最多的前5条订单订单号、数量。 select top5 with tiesorder_no,sup_id,qty fromsale_item order byqty desc 5、按部门进行汇总,统计每个部门的总工资 selectdept,sum(salary) fromemployee group bydept 6、由employee表中查找出薪水最高的员工信息。 select * fromemployee wheresalary= (selectmax(salary ) fromemployee ) 7、由sales表中查找出订单金额大于“E0013业务员在1996/10/15这天所接每一张订单的金额”的所有订单。 select * from sales wheretot_amtall (selecttot_amt fromsales wheresale_id=E0013andorder_date=1996/10/15) order bytot_amt 8、 检索product 表和sale_item表中数量大于2的相同产品的产品编号、产品名称、数量、单价。 selecta.prod_id,a.qty,a.unit_price,b.prod_name fromsale_item as a innerjoin product as b /*如果改成leftjoin/rightjoin 试分析结果*/ on (a.prod_id=b.pro_id)anda.qty2 order bya.prod_id 9、查找出employee表中住址相同的员工的姓名、性别、职称、薪水、住址。 selecta.emp_name,a.sex,a.title,a.salary,a.addr,b.emp_name,b.sex,b.title,b.salary,b.addr fromemployee as a innerjoin employee as b on(a.emp_no!=b.emp_no) and(a.emp_nameb.emp_name) and (a.addr=b.addr) 10、查找所有经理的姓名、职称、薪水。 selectemp_name,title,salary fromemployee wheretitle=’经理’ 11、查找出姓“王”并且姓名的最后一个字为“功”的员工。 select* fromemployee whereemp_namelike 王%功 12、查找住在上海或北京的女员工,并显示其姓名、所属部门、职称、住址。 selectemp_name,dept title,addr fromemployee wheresex=Fand (addr like 北京% or addr like 上海%) 13、在表sales中挑出销售金额大于等于10000元订单。 select*from sales wheretot_amt=10000 14、选取订单金额最高的前10%的订单数据。 selecttop10 percent * fromsales orderbytot_amt desc 15、查找出职称为经理或职称为职员的女员工的信息。 select*from employee wheresex=Fand ( title=经理 or title=职员) 16、删除sales表中作废的订单(其发票号码为I000000004)。 deletefromsale_item whereorder_noin (select order_no from sales whereinvoice_no=I000000004) 17、计算出一共销售了几种产品。 selectcount(distinctprod_id) fromsale_item 18、显示sale_item表中每种产品的订购金额总和,并且依据销售金额由大到小排列来显示出每一种产品的排行榜。 selectprod_id,sum(unit_price*

您可能关注的文档

文档评论(0)

sy78219 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档