1.单表查询 SELECT COUNT(CASE WHEN (字段=值列1) THEN reportstatus END) AS 已上报,COUNT(CASE WHEN (字段=值列0) THEN 字段 END) AS 未上报, 字段部门名称 AS NAME,LEFT(字段编号,限制长度6) AS CODE FROM 表名 WHERE 判断 GROUP BY LEFT(字段编号,限制长度6) 2.两表查询 SELECT a.已上报,a.未上报,a.别名,a.别名,d.关联字段 FROM ( SE…