第4-6章习题答案oracle_第1页
第4-6章习题答案oracle_第2页
第4-6章习题答案oracle_第3页
第4-6章习题答案oracle_第4页
第4-6章习题答案oracle_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、首先,从客户表customers中提取以下数据:1、输出客户声明(First_name last_name)英文字母数最多的客户数据select * from customers where length(First _ 2)。输出所有客户的资料。如果生日是空的,则替换为1970年1月1日;如果电话是空的,则替换为0。Selectcustomer _ id,first _ name,last _ name,nvl (DOB,to _ date (1970 01 01,yyyyymmdd)输出1970年六月一日前出生的所有客户资料。其中生日(DOB)的输出格式已更改为“xxxx年xx月xx日”s

2、elect customer _ id、first _ name、last _ name Mm)| |月| | to6、统计年龄超过45岁的客户数select count(*)from customers where months _ between(sysdate,DOB)/1245;7、客户姓名、客户生日和客户生日所在的月几日select first _ name | | | last _ name,DOB,to _ char (last _ day (DOB 8,)(无统计数据的商品类型为空的商品)select count(distinct product _ type _ id)fro

3、m products where product _ type _ id is not null;2、商品说明信息(description)中与music牙齿的商品数量select count(*)from products where description like % music %;select count(*)from products where instr(description,music)0;3、说明信息祖怀中与alien牙齿的商品价钱合计。其中alien中的任何字符都可以是大写或小写的select sum(price)from products where lower(de

4、scription)like % alien %。4、输出所有商品材料,并将“说明信息”(description)作为所有大写的select product _ id、product _ type _ id、name、upper (description)输出所有商品资料,并将其中说明信息(description)中的小写字母a全部更改为大写a,其他字符保持不变。Select product _ id,product _ type _ id,name,replace(说明,a,a),price from products,7。打印所有商品资料。其中描述信息中的小写a全部为大写a,大写a全部为小

5、写a,其他字符保持不变。Select product _ id,product _ type _ id,name,replace (replace,description,a,_出口最贵的商品和最便宜的商品的差别是多少?select max(price)-min(price)from products;9、根据商品类型(product_type_id),舍入为每个商品类型的平均价钱,小数点后两位。Select product _ type _ id,round (avg (price),2)from products group by product _ type _ id;10、根据商品类型

6、(product_type_id)计算每个类别的商品总数。Select product _ type _ id,count(*)from products group by product _ type _ id;11、基于商品类型(product_type_id)统计价钱合计的大于40的商品类型(product_type_id)、商品总数和商品价钱合计select product _ type _ id12,输出价钱最近的平均价钱产品名select name from products where ABS(price)-(select avg(price)from products)=(se

7、lect min()五、在采购记录表purchases、商品表products、商品类型表product_types中输出以下数据1、按商品类型分类(product_type_id)、销售量最高的商品类型及其类型名称Seles 销售前三名商品类型及其类型名称select product_type_id,Name from product _ types where product _ type _ id in(select product _ type _ id 3、输出商品类型分类(product_type_id)、销售后3位数的商品类型及其类型名称select product_type_id。name from product _ types where product _ type _ id in(select product _ type _ id from)六、商品表products和商品类型表product_types中的以下数据1,输出最贵商品的相应商品类型名称(Product _ types . name)select name from Product _ types wheresproduct _ types . name order by avg(price)desc where row num(select avg(pr

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论