日期:2014-05-17 浏览次数:20770 次
select a.fenlei, count(*), count(*)/(select count(*) from test)*100 as percentage, constitute
from test a, (select fenlei, group_concat(mc,',',cnt) as constitute from
(select fenlei, mc, count(*) as cnt from test group by 1,2) t group by 1) t1
where a.fenlei=t1.fenlei
group by 1
Array
(
[0] => Array
(
[fenlei] => 北京
[count(*)] => 2
[percentage] => 25.0000
[constitute] => 服务好,1,卫生好,1
)
[1] => Array
(
[fenlei] => 上海
[count(*)] => 4
[percentage] => 50.0000
[constitute] => 服务好,2,卫生好,2
)
[2] => Array
(
[fenlei] => 天津
[count(*)] => 2
[percentage] => 25.0000
&nbs