mysql中 使用group by时想计算出全部总数,而不是每个分组的总数时。
sql这样写

select count(1) from (select id from tabel group by colum ) count

在后面一定要赋别名,这里用的count,要不然会有Every derived table must have its own alias报错

Logo

更多推荐