zoukankan      html  css  js  c++  java
  • SQL——分组操作符与聚集函数(数据统计综合应用)

    任务描述:

    本关使用的关系说明:

    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

  • 相关阅读:
    内部类
    java的静态方法多态和匿名对象
    java的重载 和重写
    java多态成员的特点
    java 接口的概念
    linux时间修改-hwclock和date
    mysql配置主从复制和常见问题
    mysql日志种类、二进制日志模式、mysqlbinlog解析二进制日志
    mysql主从复制介绍
    mysql备份与还原-mysqldump备份、mysql与source还原
  • 原文地址:https://www.cnblogs.com/junfblog/p/12766424.html
Copyright © 2011-2022 走看看