2026-04 淘宝 简单

淘宝用户运营团队需要了解用户的年龄和性别分布,为精准营销提供数据支持。

现有用户基本信息表 tb_cst_bas_inf(用户ID、性别、年龄)。

请编写SQL查询,统计各年龄段(18-25、26-35、36-45、46+)各性别的用户数。输出年龄段、性别、用户数。

聚合函数 group by case when count

tb_cst_bas_inf

cust_uidgdrage
3000100M39
3000101F39
3000102M19
3000103M32
3000104M59

输出结果示例:

age_groupgenderuser_cnt
18-25岁500
18-25岁600
26-35岁800

ID121 餐饮类别丰富度标签  
简单 group by case when count >= 聚合函数 画像标签开发 美团
ID130 每个商品的用户性别分布  
中等 group by case when count 行列转化 购物漏斗分析 拼多多
ID197 CASE WHEN-男女学生的数量
入门 group by case when count Week44打卡 经典-学生表课程表 小猿搜题
ID198 CASE WHEN-老中青教师数量
入门 group by case when count >= Week43打卡 经典-学生表课程表 小猿搜题
ID385 电商(一)订单时段分布  
中等 group by case when count 时间日期 聚合函数

 点击下方空白区域即可查看参考答案

MySQL 8.0

00:00