如NeedleStick 表中 Job列里面的数据项 ,相同项的个数,以及百分比:
select Job, count(Job),convert(varchar,(convert(float,count(Job))/convert(float,(select count(Job) from NeedleStick)))*100) +'%' from NeedleStick group by Job having Job <> ''
如果要让百分比 保留两位小数 :
select Job, count(Job),convert(varchar,convert(decimal(10,1),(convert(float,count(Job))/convert(float,(select count(Job) from NeedleStick)))*100))+'%' from NeedleStick group by Job having Job <> ''