zoukankan      html  css  js  c++  java
  • SQL------聚集函数

     首先你要知道 where->group by->having->order by/limit  ,这个就是写sql语句时的顺序

    5种常用的聚集函数

      MAX    求最大

      MIN    求最小

      SUM        求和

      AVG   求平均

      COUNT     计算总行数

    注意:聚集函数不支持父子关联。例如:

    Drop TABLE if exists t1;

    drop table if exists t2;

    create table t2(a int, b int, c int);

    insert into t2 values(1,2,3);

    insert into t2 values(2,2,2);

    insert into t2 values(2,2,2);

    insert into t2 values(3,2,2);

    commit;

    select b, c case when c > (select avg(t.b) from t2 ) then 1 else 0 end as d from t2 t group by c, b order by 1;   --该语句正常执行结果是要报错的。报错是正常的,不报错则有问题。

    drop table if exists t2;

  • 相关阅读:
    尚未笔记知识点
    jsonp的原理及其使用
    django中将views.py中的python方法传递给html模板文件
    UVA
    UVA
    UVA
    UVA
    UVA
    UVA 1600 Patrol Robot
    UVA
  • 原文地址:https://www.cnblogs.com/kennyael/p/9938784.html
Copyright © 2011-2022 走看看