城院数据库系统原理实验(共9页).doc

上传人:飞****2 文档编号:9090909 上传时间:2022-03-30 格式:DOC 页数:9 大小:1.23MB
返回 下载 相关 举报
城院数据库系统原理实验(共9页).doc_第1页
第1页 / 共9页
城院数据库系统原理实验(共9页).doc_第2页
第2页 / 共9页
点击查看更多>>
资源描述

《城院数据库系统原理实验(共9页).doc》由会员分享,可在线阅读,更多相关《城院数据库系统原理实验(共9页).doc(9页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、精选优质文档-倾情为你奉上分别用相关子查询和不相关子查询,查询没有生成过订单的员工姓名.select LastName,FirstNamefrom Employeeswhere not exists(select *from Orderswhere Employees.EmployeeID=EmployeeID)select LastName,FirstNamefrom Employeeswhere EmployeeID in(select EmployeeIDfrom Orderswhere Employees.EmployeeIDOrders.EmployeeID)查询自己下级生成的订单数

2、量最多的员工.(注:每个下级员工的订单数和最多)select employeeidfrom Employeeswhere employeeid in(select employeeidfrom ordersgroup by employeeid having count(orderid)=all(select count(orderid) from ordersgroup by employeeid)and reportsto is not null查询订单最多的城市名称。select shipcityfrom Ordersgroup by shipcity having count(orde

3、rid)=all(select count(orderid) from Ordersgroup by shipcity)查询订单数量最多的产品的供应商select companyname from supplierswhere supplierid in(select supplierid from productswhere productid in(select productidfrom orderdetailsgroup by productid having count(orderid)=all(select count(orderid)from orderdetailsgroup

4、by productid)查询订单金额最高的员工姓名select LastName,FirstNamefrom Employeeswhere employeeid in(select employeeidfrom orderswhere orderid in(select orderid from orderdetailswhere quantity*Unitprice=(select max(quantity*Unitprice)from orderdetails)查询产品种类数最多的供应商名称select supplierid from productsgroup by supplieri

5、d having count(productid)=all(select count(distinct productid) from productsgroup by supplierid)将订单数最多的员工的备注信息改为”优秀员工”update employeesset notes=优秀员工where employeeid in(select employeeid from ordersgroup by employeeid having count(orderid)=all(select count(orderid) from orders group by employeeid)通过一

6、个SQL语句建立表,字段包括产品ID,产品名称,订单中产品总量(其中产品ID为主码),并通过一个SQL语句填充这张表.insert into chanpinselect b.productid,a.productname,count(quantity)from OrderDetails b,products awhere a.productid=b.productidgroup by b.productid,a.productname在员工表中找一个员工,删除这个员工相关的所有数据(多个SQL语句)select * from employeesselect * from orders where employeeid=8delete from employees where employeeid=8;delete from orders where employeeid=8;delete from orderdetails where orderid in(select orderid from orders where employeeid=8)专心-专注-专业

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 应用文书 > 教育教学

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁