zoukankan      html  css  js  c++  java
  • Mysql count(1) group_concat 高级用法(count 过滤条件,group_concat过滤条件)

    1、官方文档:

         count:COUNT(expr) [over_clause]

                  https://dev.mysql.com/doc/refman/8.0/en/group-by-functions.html#function_count

    1.1 实例:

        

    
    


    select update_time,sid,group_concat(if(age > '1', tid, NULL)),count(DISTINCT if(age =1,tid,null)) as current_t

    from tb_s_members group by update_time,sid order by update_time desc 

     select a.gid,a.t_m,ifnull(b.h_c,0) as hc,(a.t_m-ifnull(b.h_c,0)) as l_c from 
    (select mem.gid as gid,count(distinct mid) as t_m from members mem group by gid) as a left join
    (select gid,count(distinct mid) as h_c from members_history group by gid) as b on a.gid = b.gid;

    2、group_concat 官方文档:

       

    GROUP_CONCAT([DISTINCT] expr [,expr ...]
                 [ORDER BY {unsigned_integer | col_name | expr}
                     [ASC | DESC] [,col_name ...]]
                 [SEPARATOR str_val])

    https://dev.mysql.com/doc/refman/8.0/en/group-by-functions.html#function_group-concat
  • 相关阅读:
    事务的隔离级别
    事务的隔离
    事务简介
    leetcode647
    leetcode394
    leetcode96
    leetcode814
    leetcode738
    leetcode621
    leetcode763
  • 原文地址:https://www.cnblogs.com/cbugs/p/9340751.html
Copyright © 2011-2022 走看看