Php outputs table content quickly and efficiently .. Php outputs table content quickly and efficiently. For example, I now have a test table. Id, fenlei, and mc are represented respectively, id, automatic growth, fenlei, and mc in the participating regions. the specific selection parameter id & nbsp; & n how php outputs table content is quick and efficient ..
Php outputs table content quickly and efficiently.
For example, I now have a test table.
There are IDs, fenlei, mc
Id, automatic growth,
Fenlei, participating regions
Mc, specific selection parameters
Id fenlei mc
1 Beijing health care
2 Shanghai health care
3. good service in Shanghai
4 Tianjin health care
5. good service in Tianjin
6. good service in Beijing
7 Shanghai health care
8. good service in Shanghai
I want to make a statistics on this table .. Use the program to output the following table.
I want to separate statistics
Share:
------ Solution --------------------
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