在统计函数中添加统计条件
COUNT(1)
统计函数 COUNT(CASE WHEN 条件 THEN 1 END)
SELECT COUNT(1) AS sum, // 总数
COUNT(CASE WHEN `sex` = 1 THEN 1 END) AS boy, // 男孩
COUNT(CASE WHEN `sex` = 2 THEN 1 END) AS girl, // 女孩
COUNT(CASE WHEN `age` between 18 and 55 THEN 1 END) AS adult, // 成人
FROM `sys_user` WHERE `status` = 0 // 未被删除的