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

  • 相关阅读:
    微信小程序知识点梳理
    Vue基础知识梳理
    JQuery总结
    JS实现简单斗地主效果
    JS应用猜数游戏
    JS创建一个数组1.求和 2.求平均值 3.最大值 4.最小值 5.数组逆序 6.数组去重 0.退出
    JS数组的基本操作方法
    JS,ATM代码
    简单理解Vue中的nextTick
    Vue keep-alive实践总结
  • 原文地址:https://www.cnblogs.com/junfblog/p/12766424.html
Copyright © 2011-2022 走看看