SELECT age_range,count(*) FROM
(SELECT IF(IFNULL(age,0)>=25,"25岁及以上","25岁以下") as age_range,device_id FROM user_profile) AS user_profile
GROUP BY age_range
SELECT IF(IFNULL(age,0)>=25,"25岁及以上","25岁以下") as age_range,count(*) FROM user_profile GROUP BY age_range
SELECT device_id,gender,
CASE
WHEN age<20 then '20岁以下'
WHEN age<25 then '20-24岁'
WHEN age>=25 then '25岁及以上'
else '其他'
END as age_cunt
FROM user_profile