----按省份统计
SELECT
count(*) as total,
case SUBSTRING(t.csfzh,0,3)
when '11' then '北京市'
when '12' then '天津市'
when '13' then '河北省'
when '14' then '山西省'
when '15' then '内蒙古自治区'
when '21' then '辽宁省'
when '22' then '吉林省'
when '23' then '黑龙江省'
when '31' then '上海市'
when '32' then '江苏省'
when '33' then '浙江省'
when '34' then '安徽省'
when '35' then '福建省'
when '36' then '江西省'
when '37' then '山东省'
when '41' then '河南省'
when '42' then '湖北省'
when '43' then '湖南省'
when '44' then '广东省'
when '45' then '广西壮族自治区'
when '46' then '海南省'
when '50' then '重庆市'
when '51' then '四川省'
when '52' then '贵州省'
when '53' then '云南省'
when '54' then '西藏自治区'
when '61' then '陕西省'
when '62' then '甘肃省'
when '63' then '青海省'
when '64' then '宁夏回族自治区'
when '65' then '新疆维吾尔自治区'
when '71' then '台湾省'
when '81' then '香港特别行政区'
when '82' then '澳门特别行政区'
else '未知'
end AS province
FROM 表名 t WHERE SUBSTRING(t.csfzh,0,3)<>'37' AND BTH=0 AND IBRJZZT<>0 AND CKSMC<>'急诊科'
group by case SUBSTRING(t.csfzh,0,3)
when '11' then '北京市'
when '12' then '天津市'
when '13' then '河北省'
when '14' then '山西省'
when '15' then '内蒙古自治区'
when '21' then '辽宁省'
when '22' then '吉林省'
when '23' then '黑龙江省'
when '31' then '上海市'
when '32' then '江苏省'
when '33' then '浙江省'
when '34' then '安徽省'
when '35' then '福建省'
when '36' then '江西省'
when '37' then '山东省'
when '41' then '河南省'
when '42' then '湖北省'
when '43' then '湖南省'
when '44' then '广东省'
when '45' then '广西壮族自治区'
when '46' then '海南省'
when '50' then '重庆市'
when '51' then '四川省'
when '52' then '贵州省'
when '53' then '云南省'
when '54' then '西藏自治区'
when '61' then '陕西省'
when '62' then '甘肃省'
when '63' then '青海省'
when '64' then '宁夏回族自治区'
when '65' then '新疆维吾尔自治区'
when '71' then '台湾省'
when '81' then '香港特别行政区'
when '82' then '澳门特别行政区'
else '未知' END order by total desc
----按市区统计
SELECT count(*) as total,
case SUBSTRING(t.csfzh,0,5)
when '3701' then '济南市'
when '3702' then '青岛市'
when '3703' then '淄博市'
when '3704' then '枣庄市'
when '3705' then '东营市'
WHEN '3706' then '烟台市'
WHEN '3707' then '潍坊市'
WHEN '3708' then '济宁市'
WHEN '3709' then '泰安市'
WHEN '3710' then '威海市'
WHEN '3711' then '日照市'
WHEN '3712' then '莱芜市'
WHEN '3713' then '临沂市'
WHEN '3714' then '德州市'
WHEN '3716' then '滨州市'
when '3717' then '菏泽市'
when '3715' then '聊城市'
when '3723' then '滨州市'
when '3729' then '菏泽市'
when '3724' then '德州市'
when '3728' then '临沂市'
when '3725' then '聊城市'
when '3790' then '青岛市'
WHEN '3726' then '泰安市'
WHEN '3727' then '济宁市'
WHEN '3721' then '烟台市'
WHEN '3722' then '潍坊市'
ELSE csfzh
END province
FROM 表名 t
WHERE SUBSTRING(t.csfzh,0,3)='37' AND BTH=0 AND IBRJZZT<>0 AND CKSMC<>'急诊科'
GROUP BY case SUBSTRING(t.csfzh,0,5)
when '3701' then '济南市'
when '3702' then '青岛市'
when '3703' then '淄博市'
when '3704' then '枣庄市'
when '3705' then '东营市'
WHEN '3706' then '烟台市'
WHEN '3707' then '潍坊市'
WHEN '3708' then '济宁市'
WHEN '3709' then '泰安市'
WHEN '3710' then '威海市'
WHEN '3711' then '日照市'
WHEN '3712' then '莱芜市'
WHEN '3713' then '临沂市'
WHEN '3714' then '德州市'
WHEN '3716' then '滨州市'
when '3717' then '菏泽市'
when '3715' then '聊城市'
when '3723' then '滨州市'
when '3729' then '菏泽市'
when '3724' then '德州市'
when '3728' then '临沂市'
when '3725' then '聊城市'
WHEN '3790' then '青岛市'
WHEN '3726' then '泰安市'
WHEN '3727' then '济宁市'
WHEN '3721' then '烟台市'
WHEN '3722' then '潍坊市'
ELSE csfzh
END order by total desc