任务描述:
本关使用的关系说明:
product(maker,model,type)
maker:表示生产厂商
model:生产的产品型号
type:产品类型,有pc laptop两种
pc(model,speed,ram,hd,price)
表示型号,速度,内存大小,硬盘大小,价格
laptop(model,speed,ram,hd,screen,price)
表示型号,速度,内存大小,硬盘大小,屏幕大小和价格
已创建的视图:
create view V_test as
select product.maker,product.model,product.type,pc.price,pc.hd,pc.speed from product join pc on product.model=pc.model
union
select product.maker,product.model,product.type,laptop.price,laptop.hd,laptop.speed from product join laptop on product.model=laptop.model
编程要求:
1.查询在一种或两种电脑(含PC和laptop)中出现过的硬盘的容量。
select hd from V_test group by hd having count(hd)<=2
2.统计各生产厂商生产的电脑(不区分pc和laptop)的平均处理速度的最大值。
select max(R) from (select avg(speed) as from V_test group by maker) as S
select max(c) from (select maker,avg(speed) as c from v_test group by maker)R
3.统计出各厂商生产价格高于1000的产品数量,不用区分是pc还是laptop
select maker,count(model) from V_test where price>1000 group by maker
4.分别统计各厂商生产的pc,laptop的平均价格
select maker,type,avg(price) from V_test group by maker,type