本题主要考察流程函数
未学过也不用慌,我来介绍一下,常用的2个流程函数
if(条件, 成立1 , 成立2 )
case
when 条件1 then 成立1
when 条件2 then 成立2
...
else 前面都不成立,这个成立
end;
以上,就是常用的格式啦!
select
if(age<25 or age is null,'25岁以下','25岁及以上') age_cut,
count(id) number
from
user_profile
group by
age_cut;

京公网安备 11010502036488号