查询矩阵a1,a2,a3中每个数字分别出现的次数。
SELECT T.num AS 数字,COUNT(1) AS 出现的次数 FROM ((SELECT a1 AS num FROM bbc_test ORDER BY a1 ASC)
UNION ALL
(SELECT a2 AS num FROM bbc_test ORDER BY a2 ASC)
UNION ALL
(SELECT a3 AS num FROM bbc_test ORDER BY a3 ASC)) T GROUP BY T.num;
结果如下: