问题分解: 限定条件:无; 每个学校每种性别:按学校和性别分组:group by gender, university 用户数:count(device_id) 30天内平均活跃天数:avg(active_days_within_30) 平均发帖数量:avg(question_cnt) 细节问题: 表头重命名:as 注意输出顺序,与示例保持一致 完整代码:
select gender, university, count(device_id) as user_num, avg(active_days_within_30) as avg_active_days, avg(question_cnt) as avg_question_cnt from user_profile group by gender, university