资源描述:
《数据库实训操作题参考答案》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、销售管理数据库的操作题销售管理数据库的数据查询1.查询员工"王娜"所在的部门。selectDepartmentNamefromDepartmentwhereDepartmentID=(selectDepartmentIDfromEmployeewhereEmployeeName='姚安娜')2.查询年龄最小的员工姓名、性别和工资。selectEmployeeName姓名,Sex性别,BirthDate出生年月,Salary工资fromEmployeewhereBirthDate=(selectMAX(BirthDate)fromEmployee)--年龄最小就是出生年月最大,利用嵌套
2、查询,查询最大出生年月3.查询已经接收销售订单的员工姓名和工资信息。(用两种方法做:嵌套查询、相关子查询)--嵌套查询方法:SelectEmployeeName姓名,Salary工资fromEmployeewhereEmployeeIDin(selectEmployeeIDfromSell_Order)--相关子查询方法:SelectEmployee.*fromEmployeewhereexists(select*fromSell_OrderwhereSell_Order.EmployeeID=Employee.EmployeeID)4.查询订购“牛奶”的客户信息。(用两种方法做:嵌
3、套查询、连接查询)--嵌套查询:selectCompanyName公司名称,ContactName联系人,Address地址fromCustomerwhereCustomerIDIN(selectCustomerIDfromSell_OrderwhereProductID=(selectProductIDfromProductwhereProductName='牛奶'))--连接查询:selectCompanyName公司名称,ContactName联系人,Address地址fromCustomerjoinSell_OrderonCustomer.CustomerID=Sell_Or
4、der.CustomerIDjoinProductonProduct.ProductID=Sell_order.ProductIDwhereProduct.ProductName='牛奶'5.查询所有员工姓名、性别、出生年月和所在部门信息。selectDepartmentID部门号,EmployeeName姓名,Sex性别,BirthDate出生年月,部门名称=caseDepartmentIDWHEN1THEN'销售部'otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthen
5、ewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofthelongMarch,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSec
6、retaryandrecorderoftheCountypartyCommitteeSecretary,MinistersandWHEN2THEN'采购部'WHEN3THEN'人事部'else'其他部门'endfromEmployeegroupbyDepartmentID,EmployeeName,Sex,BirthDate6.查询1980年后出生的员工的信息(姓名、性别、出生年月和工资)。selectEmployeeName姓名,Sex性别,year(BirthDate)出生年月,Salary工资fromEmployeewhereBirthDate>'1980-01-01'补充:查
7、询1980年-1989年间出生的员工的信息(姓名、性别、出生年月和工资)。selectEmployeeName姓名,Sex性别,year(BirthDate)出生年月,Salary工资fromEmployeewhereconvert(char(4),year(BirthDate),102)like'198[0-9]'销售管理数据库编程1.员工“王江娜”与“华农楚天”签订了25台显示器订单。编程实现将订单涉及的相关信息写入到数据库中。提示步骤:a)客户处理: