一、case when 统计
SELECT
COUNT(*) user_count,
COUNT(CASE
WHEN sex = '0' THEN sex
END) AS un_known_count,
COUNT(CASE
WHEN sex = '1' THEN sex
END) AS male_count,
COUNT(CASE
WHEN sex = '2' THEN sex
END) AS female_count
FROM
user;
网友评论