SELECT Bj, ;
SUM(IIF(ALLTRIM(语文)=="M",1,0)) 语文M, SUM(IIF(ALLTRIM(语文)=="缺考",1,0)) 语文缺考,
SUM(IIF(ALLTRIM(语文)=="空值",1,0)) 语文空值, ;
SUM(IIF(ALLTRIM(数学)=="M",1,0)) 数学M, SUM(IIF(ALLTRIM(数学)=="缺考",1,0)) 数学缺考,
SUM(IIF(ALLTRIM(数学)=="空值",1,0)) 数学空值, ;
SUM(IIF(ALLTRIM(外语)=="M",1,0)) 外语M, SUM(IIF(ALLTRIM(外语)=="缺考",1,0)) 外语缺考,
SUM(IIF(ALLTRIM(外语)=="空值",1,0)) 外语空值, ;
FROM g:\bj GROUP BY Bj
如果要三类人员的合计数代码如下
SELECT Bj, ;
SUM(IIF(ALLTRIM(语文)=="M",1,0)) + SUM(IIF(ALLTRIM(语文)=="缺考",1,0)) + SUM(IIF(ALLTRIM(语文)=="空值",1,0)) 语文M缺空, ;
SUM(IIF(ALLTRIM(数学)=="M",1,0)) + SUM(IIF(ALLTRIM(数学)=="缺考",1,0)) + SUM(IIF(ALLTRIM(数学)=="空值",1,0)) 数学M缺空, ;
SUM(IIF(ALLTRIM(外语)=="M",1,0)) + SUM(IIF(ALLTRIM(外语)=="缺考",1,0)) + SUM(IIF(ALLTRIM(外语)=="空值",1,0)) 外语M缺空, ;
FROM g:\bj GROUP BY Bj
[此贴子已经被作者于2024-4-24 11:22编辑过]