如何统计一行记录相同列值的总数?【在线等】
有这样的一条记录:
表名table1
id p1 p2 p3 p4 p5 p6
1 a c a b b d
输出结果为:
A B C D
2 2 1 1
如何实现呢?在线等
[解决办法]
select p1,count(1)from (select p1 from table1union allselect p2 from table2union allselect p3 from table3union allselect p4 from table4union allselect p5 from table5union allselect p6 from table6) agroup by p1