Advertisement

MySQL查找某个年龄段用户

阅读量:

描述
题目:
当前运营方计划对年龄在20岁及以上、同时不超过23岁的用户群体进行相关分析,请提取符合该年龄段的设备ID、性别以及年龄信息。

用户信息表:user_profile

id device_id gender age university province
1 2138 male 21 北京大学 Beijing
2 3214 male 复旦大学 Shanghai
3 6543 female 20 北京大学 Beijing
4 2315 female 23 浙江大学 Zhejiang
5 5432 male 25 山东大学 Shandong

根据输入,你的查询应返回以下结果:

device_id gender age
2138 male 21
6543 female 20
2315 female 23
复制代码
    select
      device_id,
      gender,
      age
    from
      user_profile
    where
      age between 20 and 23
      and age is not null;
      

全部评论 (0)

还没有任何评论哟~