紫薯韧性十足
紫薯韧性十足
全部文章
分类
归档
标签
去牛客网
登录
/
注册
紫薯韧性十足的博客
TA的专栏
9篇文章
0人订阅
SQL练练练
9篇文章
1383人学习
全部文章
(共8篇)
记录 substing() 和 substring_index()函数用法
select case SUBSTRING_INDEX (profile, ',', -1) when 'female' then 'female' else 'male' end as gender, count(*) as ...
2025-03-10
1
413
记录regexp与rlike | 计算用户8月每天的练题数量
来自专栏
--regexp运算符 select day(date) as day, count(question_id) as question_cnt from question_practice_detail where date regexp '2021-08' group by day...
2025-03-10
1
166
记录 SQL 语句 遇到的错误 | 行列变换
来自专栏
找错误先看错误代码: select ( case age when age >= 25 then '25岁及以上' else '25岁以下' end ) as age_cut, count(...
2025-03-10
1
166
记录union 和 union all的具体用法及区别
来自专栏
UNIONUNION 操作符用于合并两个或多个 SELECT 语句的结果集,并自动去除重复的记录。因此,UNION 的结果集中不会有重复的行。需要注意的是,UNION 在执行时会进行排序操作以删除重复行,这可能会导致性能下降,特别是在处理大数据集时。语法 SELECT column1, column...
2025-03-10
1
290
题解 | 统计每个学校各难度的用户平均刷题数
来自专栏
select university, difficult_level, count(qpd.device_id) / count(distinct qpd.device_id) as avg_answer_cnt from user_profile u, qu...
2025-03-09
1
141
题解 | 统计每个学校的答过题的用户的平均答题数
来自专栏
select university,count(question_id) / count(distinct q.device_id) as avg_answer_cnt from user_profile u join question_practice_detail q on u.device_...
2025-03-09
1
117
题解 | 查询结果限制返回行数
来自专栏
# 自写:使用limit select device_id from user_profile limit 2; # 两个参数表示从0开始,访问2条即1-2, select device_id from user_profile limit 0,2; # offset表示从表头跳过*条,这里跳过0条...
2025-03-09
1
131
题解 | 查询结果去重
来自专栏
# 方法一:关键字distinct select distinct university from user_profile; # 方法二:分组 group by 同样能达到去重效果 select university from user_profile group by university; 记...
2025-03-09
1
153