mysql count group by統計條數方法
mysql 分組之后如何統計記錄條數? gourp by 之后的 count,把group by查詢結果當成一個表再count一次
select count(*) as count from
(SELECT count(*) FROM 表名 WHERE 條件 GROUP BY id ) a;
實戰例子:
select
count(*) as total
from (select count(*) from users group by user_id) u
