原始sql:
select count(A) gjj, count(B) sbj, count(C) xj
from 表名
where dwbh = 'A';
原始结果图 :
列转行后sql:
select count(C)AS 新列名,'xj' AS '新列名'
from 表名
where dwbh = 'A'
UNION ALL
select count(A) AS 新列名,'gjj' AS '新列名'
from 表名
where dwbh = 'A'
UNION ALL
select count(B) AS 新列名,'sbj' AS '新列名'
from 表名
where dwbh = 'A'
列转行效果图: