|
TRY:建立临时表,内容为A-Z,你可以更改成你的数据,假设字段最大容量为3个字符,你可以更改,思路是这样,SQL语句:
SELECT B1,SUM(JS) FROM (
SELECT A.B1,COUNT(*) AS JS FROM (
SELECT mid(bh,1,1) AS b1, nz(mid(bh,2,1),'') AS b2, nz(mid(bh,3,1),'') AS b3, *
FROM a41) A
LEFT JOIN ZMB B ON A.B1=B.ZM GROUP BY A.B1
UNION ALL SELECT A.B2,COUNT(*) AS JS FROM (
SELECT mid(bh,1,1) AS b1, nz(mid(bh,2,1),'') AS b2, nz(mid(bh,3,1),'') AS b3, *
FROM a41) A
LEFT JOIN ZMB B ON A.B2=B.ZM GROUP BY A.B2
UNION ALL SELECT A.B3,COUNT(*) AS JS FROM (
SELECT mid(bh,1,1) AS b1, nz(mid(bh,2,1),'') AS b2, nz(mid(bh,3,1),'') AS b3, *
FROM a41) A
LEFT JOIN ZMB B ON A.B3=B.ZM GROUP BY A.B3) WHERE B1<>' ' GROUP BY B1
|
|