1、mysql语句实现年龄分布
select nnd as '年龄段',count(*) as '人数' from(
select
case
when age>=1 and age<=10 then '1-10'
when age>=11 and age<=20 then '11-20'
when age>=21 and age<=30 then '21-30'
when age>=31 and age<=40 then '31-40'
when age>=41 and age<=50 then '41-50'
when age>=51 and age<=60 then '51-60'
when age>=61 and age<=70 then '61-70'
when age>=71 and age<=80 then '71-80'
when age>=81 and age<=90 then '81-90'
when age>=91 and age<=100 then '91-100'
ELSE '无年龄' end
as nnd from doc_info
)a group by nnd
2、查找病历中包含逗号的诊断数量
SELECT count(diag) FROM `doc_info_hive` where LOCATE(',',diag)>0 ;
3、查找病例中不包含逗号的诊断数量
SELECT count(diag) FROM `doc_info_hive` where LOCATE(',',diag)=0 ;