题解 | #条件查询#
计算25岁以上和以下的用户数量
http://www.nowcoder.com/practice/30f9f470390a4a8a8dd3b8e1f8c7a9fa
case语句进行书写 select (case when age>=25 then '25岁以上' else '25岁以下' end) as age_cut, count() as number from user_profile group by age_cut if语句进行书写 SELECT IF(age>=25,"25岁及以上","25岁以下") AS age_cut, count() AS number FROM user_profile GROUP BY age_cut;
count(*)对表中行的数目进行计数,不管表中包含的是空值(null)还是非空值。 当select中得到的列在原来的表中没有对应的列时处理方法。