一个简单的 分组 计算组内记录数占比的 语句
select b as 标识,COUNT(*) AS 数量,(select COUNT(*) from num) as 总数量,(ltrim(cast(count(*)*100./nullif((select count(*) from num),0) as decimal(12,2)))+'%')
as 占比 from num group by b order by 数量
本文来自博客园,作者:忙碌在路上,转载请注明原文链接:https://www.cnblogs.com/netsa/archive/2012/04/07/2436047.html