# 子查询--在user_profile添加分组列,为各行添加年龄分组标记 select *, case when age<25 or age is null then '25岁以下' else '25岁及以上' end as age_cut from user_profile # 完整查询--返回这两个年龄段的用户数量 select age_cut, count(*) number from ( select *, case when age<25 or age is null then '25岁以下' else '25岁及以上' end as age_cut from user_profile ) age_f group by age_cut;