zoukankan      html  css  js  c++  java
  • oracle数据库之组函数

    组函数也叫聚合函数,用来对一组值进行运算,并且可以返回单个值

    常见的组函数:

    (1)count(*),count(列名)  统计行数找到所有不为 null 的数据来统计行数

    (2)avg(列名)  平均数

    (3)sum(列名)  求和

    (4)max(列名)  求最大值

    (5)min(列名)  求最小值

    scottoracle中的一个示范用户,主要用于测试。它自带一些测试用的数据方便我们测试,由于是oracle中的一个对象,因此scott.emp表示数据库中的员工表。

    -- 首先,查看emp 中的所有数据。

    select * from scott.emp;

    --1统计 emp 表中的总行数

    select count(*) from scott.emp;

     

    --统计 emp 表中属性列为ename的总行数

    select count(ename) from scott.emp;

     

    --统计 emp 表中属性列为comm的总行数,由于有10项为空,所以行数为4

    select count(comm) from scott.emp;

     

    --2平均值

    -- 统计 emp 表中属性列为comm平均奖金。

    -- 一般做法,平均奖金 = 总奖金/总员工数。

    select sum(comm) / count(comm) from scott.emp;

    -- 使用 avg() 求均值

    select avg(sal) from scott.emp;

     

    --3)使用sum() 求和

    select sum(sal) from scott.emp;

     

    --4最大

    select max(sal) from scott.emp;

     

    --5最小值

    select min(sal) from scott.emp;

     

     

     

  • 相关阅读:
    HDU 4825 字典树
    HDU4287 字典树
    HDU 3973 AC's String 字符串哈希
    HDU5296 Annoying problem(LCA)
    Gym 100712L Alternating Strings II(单调队列)
    数据结构专题
    HDU5033 Building(单调栈)
    HDU2888 Check Corners(二维RMQ)
    HDU 4123 Bob’s Race(RMQ)
    HDU3530 Subsequence(单调队列)
  • 原文地址:https://www.cnblogs.com/yifeiyaoshangtian/p/9440686.html
Copyright © 2011-2022 走看看