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

  • 相关阅读:
    关于线程间通信的条件变量
    vim学习相关链接
    CString与输入输出流对象问题。
    CRect类 的介绍
    在vs中char类型的实参与LPCWSTR类型的形参类型不兼容怎么解决?
    ADO Recordset 对象链接
    FIND_IN_SET的简单使用
    html meta标签作用
    github新建托管项目及上传项目
    Javascript编码规范
  • 原文地址:https://www.cnblogs.com/junfblog/p/12766424.html
Copyright © 2011-2022 走看看