zoukankan      html  css  js  c++  java
  • mysql高级聚合

    GROUP_CONCAT()

    函数的值等于属于一个组的指定列的所有值,以逗号隔开,并且以字符串表示

    mysql> select sex,group_concat(level) from role group by sex;
    +------+---------------------+
    | sex  | group_concat(level) |
    +------+---------------------+
    |    0 | 8,4,91              |
    |    1 | 10,20,20,29,60      |
    +------+---------------------+
    2 rows in set (0.00 sec)

    with rollup子句:用来要求在一条group by子句中进行多个不同的分组

    mysql> select sex,count(1) from role group by sex with rollup;
    +------+----------+
    | sex  | count(1) |
    +------+----------+
    |    0 |        3 |
    |    1 |        5 |
    | NULL |        8 |
    +------+----------+
    3 rows in set (0.00 sec)

  • 相关阅读:
    mysql--主从复制
    Linux--部署Vue项目
    Linux--安装node.js
    Linux--防火墙和vim
    go.js
    服务端和客户端通信的三种方式
    mysql-排序过程
    数据分析-Numpy
    shell
    Linux-crontab
  • 原文地址:https://www.cnblogs.com/playforever/p/9336820.html
Copyright © 2011-2022 走看看