体重指数这一列,统计不同分类的人数,依据中国bmi分类范围:
结果:
select count(*),
case when NBMI < 18.5 then '体重过低'
when NBMI >= 18.5 and NBMI <24 then '体重正常'
when NBMI >= 24 then '超重'
when NBMI >=24 and NBMI <28 then '肥胖前期'
when NBMI >=28 and NBMI <30 then '一度肥胖'
when NBMI >=30 and NBMI <40 then '二度肥胖'
when NBMI >= 40 then '三度肥胖' else null end
from TBJKTJ GROUP BY
case when NBMI < 18.5 then '体重过低'
when NBMI >= 18.5 and NBMI <24 then '体重正常'
when NBMI >= 24 then '超重'
when NBMI >=24 and NBMI <28 then '肥胖前期'
when NBMI >=28 and NBMI <30 then '一度肥胖'
when NBMI >=30 and NBMI <40 then '二度肥胖'
when NBMI >= 40 then '三度肥胖' else null end;