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 数量