sele gh,xm,sum(iif(allt(cd)=="迟",1,0)) cd,sum(iif(allt(zt)=="早",1,0)) zt,sum(iif(allt(kb)=="旷半",1,0)) kb,sum(iif(allt(kq)=="旷全",1,0)) kq from b201510 grou by gh
SELECT gh,xm,SUM(IIF(ALLTRIM(cd)='迟',1,0)) cd,SUM(IIF(ALLTRIM(zt)='早',1,0)) zt,SUM(IIF(ALLTRIM(kb)='旷半',1,0)) kb,SUM(IIF(ALLTRIM(kq)='旷全',1,0)) kq FROM 201510 GROUP BY gh,xm