Half-
Half-
全部文章
分类
题解(59)
归档
标签
去牛客网
登录
/
注册
Half-的博客
TA的专栏
45篇文章
0人订阅
sql刷题笔记
45篇文章
457人学习
全部文章
(共45篇)
题解 | #牛客的课程订单分析(二)#
来自专栏
思路:having count selectuser_idfrom order_infowhere date > '2025-10-15'and status = 'completed'and product_name in ('C++','Java','Python')group by us...
2021-07-27
0
243
题解 | #考试分数(五)#
来自专栏
select * from order_info where date > '2025-10-15' and status = 'completed' and product_name in ('C++','Java','Python') order by id
2021-07-27
0
309
题解 | #考试分数(五)#
来自专栏
思路:中位数正序>=1/2 total 倒序也一样selectid,job,score,rk2 t_rankfrom( select * ,count(score)over(partition by job) as total ,row_number()over(par...
2021-07-26
0
232
题解 | #考试分数(四)#
来自专栏
思路:中位数的计算方法,开始位置floor((max+min)/2),结束位置需要判断奇偶,奇数+1,偶数不变selectjob,floor((max(rk)+min(rk))/2) start,if((max(rk)+min(rk)) mod 2 = 1,floor((max(rk)+min(rk...
2021-07-26
0
311
题解 | #考试分数(三)#
来自专栏
思路:dense_rank()selectg.id,name,scorefrom( select g.id ,name ,score ,row_number(partition by name order by score desc) rk from grade ...
2021-07-26
0
244
题解 | #考试分数(二)#
来自专栏
思路:avg()overselectid,job,scorefrom( select * ,avg(score)over(partition by job) av_g from grade) awhere score > av_gorder by 1
2021-07-26
0
279
题解 | #牛客每个人最近的登录日期(五)#
来自专栏
思路:以刷题表为主表连接用户表,sum()over得到每个用户的每日累计刷题数 select u.name u_n ,date ,sum(number)over(partition by p.user_id order by date) ps_num from passing_numbe...
2021-07-26
0
232
题解 | #牛客每个人最近的登录日期(五)#
来自专栏
思路:次日留存率 = 这些新用户中次日登录的用户数/该日新登录用户数selectdate,round(ifnull(sum(case when f_d = date and l_d - date = 1 then 1 else 0 end)/sum(case when f_d = date then...
2021-07-26
0
253
题解 | #牛客每个人最近的登录日期(四)#
来自专栏
思路:first_value求出每个用户的最早登录日期,sum(case when)相等为1,不等为0selectdate,sum(case when f_d = date then 1 else 0 end) newfrom( select user_id ,date ,f...
2021-07-26
0
221
题解 | #牛客每个人最近的登录日期(三)#
来自专栏
selectround(sum(case when rk = 1 and date_add(date,interval 1 day) = 第二天登录 then 1 else 0 end)/count(distinct user_id),3) pfrom( select user_id ...
2021-07-23
0
360
首页
上一页
1
2
3
4
5
下一页
末页