牛客297995581号
牛客297995581号
全部文章
题解
归档
标签
去牛客网
登录
/
注册
牛客297995581号的博客
全部文章
/ 题解
(共40篇)
题解 | #截取出年龄#
select substring_index(substring_index(profile,',',-2),',',1) as age, //截取中间字符串:substring_index(substring_index())此函数灵活套娃可以解决 //强调:正负数:是指从左向右?从右向左...
Mysql
2022-03-21
2
248
题解 | #统计每种性别的人数#
select substring_index(profile,',','-1') gender, // 要分割 profile 这一列;,是分隔符;负数:从右向左取一个被截取的字符串(正数:从右向左截取) //注意: 想要截取中间部分,可以用 substring_index(substrin...
Mysql
2022-03-21
1
316
题解 | #计算用户的平均次日留存率#
select count(date2) / count(date1) as avg_ret //平均次日留存率 = 第 n 天相比前一天新增用户数量 / 第一天新增用户数量 //第二天继续刷题平均概率 = 第二天相比第一天继续刷题用户数量 / 第一天总人数 from ( select...
Mysql
2022-03-21
3
357
题解 | #计算用户8月每天的练题数量#
select day(date) as day,//取日期中的日 count(question_id) as question_cnt//统计题数 from question_practice_detail where year(date) = 2021 and month(dat...
Mysql
2022-03-19
0
210
题解 | #查看不同年龄段的用户明细#
select device_id, gender, case when age >= 25 then '25岁及以上' when age >= 20 then '20-24岁' when age < 20 ...
Mysql
2022-03-18
0
212
题解 | #统计每个学校各难度的用户平均刷题数#
select case when age >= 25 then '25岁及以上' else '25岁以下' //这里注意用else:包含 null end as age_cut, count(*) number from user_profile group by age_cut;
Mysql
2022-03-18
0
235
题解 | #统计每个学校各难度的用户平均刷题数#
select device_id,gender,age,gpa from user_profile where university = '山东大学' union all select device_id,gender,age,gpa from user_profile where gender...
Mysql
2022-03-18
1
317
题解 | #统计每个学校各难度的用户平均刷题数#
select university, difficult_level, round((count(qpd.question_id)/count(distinct qpd.device_id)),4) as avg_answer_cnt //注意:共同列必须指明来自那张...
Mysql
2022-03-18
2
335
题解 | #统计每个学校的答过题的用户的平均答题数#
select university, round((count(question_id)/count(distinct q.device_id)),4) as avg_answer_cnt //保留四位小数;计算平均做题数:每个学校总题数/每个学校用户数(设备数-设备...
Mysql
2022-03-15
1
237
题解 | #浙江大学用户题目回答情况#
select device_id,question_id,result from question_practice_detail where device_id in (select device_id from user_profile where university = '浙江大学');//...
Mysql
2022-03-13
1
221
首页
上一页
1
2
3
4
下一页
末页