• 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

  • 相关阅读:
    再看到一则有关Anders的……
    arp好烦!123.8w8w8w,自己建了一个内网的nod32升级服务器。
    在看discuz nt 1.0。
    顺便说一下,这边速度好快?
    没什么可说。
    昨天看王建硕的blog,在说《胡适日记》的事。
    c# 深复制 浅复制(转)
    foreach yield
    Array
    JQuery.fn.extend(object) jQuery.extend(object) 转
  • 原文地址:https://www.cnblogs.com/junfblog/p/12766424.html
Copyright © 2020-2023  润新知