# 筛选出25岁以上和25岁以下的人,统计人数。
select
'25岁以下' as age_cut,count(device_id) as number
from
user_profile
where
age<25 or age is Null
union
select
'25岁及以上' as age_cut,count(device_id) as number
from
user_profile
where
age >= 25;
在没学case语句的时候也可以这样写。

京公网安备 11010502036488号