在思考的六边形战士很想去旅行
在思考的六边形战士很想去旅行
全部文章
分类
归档
标签
去牛客网
登录
/
注册
在思考的六边形战士很想去旅行的博客
全部文章
(共90篇)
题解 | 计算每日累计利润
# 窗口子句:划分统计函数sum()的应用范围 # over() 将所有查询结果作为一个窗口 # over(rows between 开始位置 and 结束位置) # 开始位置|结束位置: # 窗口的第一行: unbounded preceding # 当前行: current row ...
2025-07-16
8
58
题解 | 找出每个学校GPA最低的同学
# “同校最低GPA只显示最前面一条记录”,应该使用 ROW_NUMBER() 的方法,而不是 FIRST_VALUE()。 # FIRST_VALUE() 是一个窗口函数,它不会减少结果集的行数,而是为每一行返回一个值。具体来说,它的效果是: # 对于结果集的每一行,FIRST_VALUE() ...
2025-07-16
1
34
题解 | 截取出年龄
select substring(profile,12,2) as age, count(*) as number from user_submit group by age;
2025-07-16
1
21
题解 | 统计每种性别的人数
select case # 重点是like后面应当跟'%,male'而不是'%male', # 具体原因是前者更加精确,因为female字符串也包含了male子串,所有profile字符串都like '%male', # 只有like '%,male%'的才是男性 ...
2025-07-16
1
39
题解 | 查看不同年龄段的用户明细
select device_id, gender, case when age < 20 then '20岁以下' when age between 20 and 24 then '20-24岁' when age >...
2025-07-14
1
47
题解 | 计算25岁以上和以下的用户数量
select case when age is null or age < 25 then '25岁以下' else '25岁及以上' end as age_cut, count(*) as number from user_prof...
2025-07-14
1
38
题解 | 统计每个用户的平均刷题数
# 关键是要搞清楚avg_answer_cnt的计算方式 select university, difficult_level, # 每个难度分组中, # question_id行数:该难度的问题被回答的总次数 # 不同的device_id个数:回答该难度的问题的用户数 ...
2025-07-13
1
28
题解 | 电话号码格式校验
select * from contacts where # 含"-"和不含"-"的情况分开检验 ( phone_number RLIKE '^[0-9]+$' and phone_number not like &quo...
2025-07-12
2
32
题解 | 查询下订单用户访问次数?
select user_id, count(info_id) as visit_nums from visit_tb where user_id in ( select user_id from order_tb where date(order_time) = '2022-...
2025-07-11
1
62
题解 | 最长连续登录天数
with ordered_logins as ( select user_id, fdate, # 通过row_number()、窗口函数,对每个用户的登录日志生成一个连续序列 #...
2025-07-11
1
46
首页
上一页
1
2
3
4
5
6
7
8
9
下一页
末页