1,一个表先将01,02,03类型编码转换文字,在做统计
select CASE IMPLEMENT_PROPETY WHEN ‘01‘ then ‘法定机关‘ WHEN ‘02‘ then ‘授权组织‘ WHEN ‘03‘ then ‘受委托组织‘ ELSE ‘其他‘ END MMMMMM from test.pre_service
最终sql结果如下
SELECT temp.MMMMMM WW,COUNT(*) as Total from (select CASE IMPLEMENT_PROPETY WHEN ‘01‘ then ‘法定机关‘ WHEN ‘02‘ then ‘授权组织‘ WHEN ‘03‘ then ‘受委托组织‘ ELSE ‘其他‘ END MMMMMM from test.pre_service ) temp group by temp.MMMMMM
//代码原型
select temp.type as type, count(type) as Total from (select case 字段 WHEN ‘1‘ then ‘苹果‘ WHEN ‘2‘ then ‘香蕉‘ WHEN ‘3‘ then ‘西瓜‘ end as type from table ) temp where type is not null group by temp.type
2.
//1 ---select IMPLEMENT_PROPETY , COUNT(*) Num from test.pre_service GROUP BY IMPLEMENT_PROPETY -- SELECT dept_name ,COUNT(*) AAAA from test.pre_service_snapshot GROUP BY dept_name -- SELECT dept_name, INFO_TYPE , COUNT(*) Num from test.pre_service_snapshot GROUP BY dept_name,INFO_TYPE -- SELECT dept_name,SERVICE_TYPE ,COUNT(*) Num from test.pre_service_snapshot where INFO_TYPE=‘即办件‘ group by dept_name,SERVICE_TYPE -- select DEPT_NAME ,COUNT(*) numBer from test.pre_service GROUP BY DEPT_NAME -- select IMPLEMENT_PROPETY , COUNT(*) Num from test.pre_service GROUP BY IMPLEMENT_PROPETY -- select IMPLEMENT_PROPETY , COUNT(*) Num from test.pre_service GROUP BY IMPLEMENT_PROPETY -- select DATE_FORMAT(PROMISEE_TIME,‘%Y-%m‘) date ,count(projid) num ,HANDLESTATE from test.pre_apasinfo -- group by DATE_FORMAT(PROMISEE_TIME,‘%Y-%m‘),HANDLESTATE -- -- select hander_deptname , COUNT(*) Accept_Number FROM test.pre_transact GROUP BY hander_deptname -- -- select DATE_FORMAT(TRANSACT_TIME,‘%Y-%m‘) date ,count(projid) num ,hander_deptname from test.pre_transact -- group by DATE_FORMAT(TRANSACT_TIME,‘%Y-%m‘),hander_deptname ---SELECT SUM(*) from pre_serv -- select transact_result hander_deptname , COUNT(*) Accept_Number ,hander_deptname FROM test.pre_transact GROUP BY transact_result -- select transact_result transact_result , COUNT(*) hander_Number FROM test.pre_transact GROUP BY transact_result -- select OBJECT_NAME name_institution , COUNT(*) Complain_Number FROM test.pre_complain GROUP BY OBJECT_NAME ---select hander_deptname , COUNT(*) Accept_Number FROM test.pre_transact GROUP BY hander_deptname