张多盐
张多盐
全部文章
题解
归档
标签
去牛客网
登录
/
注册
张多盐的博客
全部文章
/ 题解
(共47篇)
题解 | #牛客的课程订单分析(七)#
按照source聚合时需要用case when 判断条件 ```select case when a.is_group_buy = 'No'then c.name else 'GroupBuy' end as source ,count(product_name) as scnt from ( ...
Mysql
2021-11-09
0
199
题解 | #牛客的课程订单分析(五)#
思路: 1.首先,将满足基本条件的用户及购买日期次序,购买次数取出,作为子表 select * ,ROW_NUMBER() over(partition by user_id order by date ) as date_num ,count(*) over(partition b...
Mysql
2021-11-09
0
285
题解 | #牛客的课程订单分析(二)#
# 查询在2025-10-15以后,同一个用户下单2个以及2个以上 注意使用聚合函数时不可以跟在where后面 # 状态为购买成功的C++课程或Java课程或Python课程的user_id, # 并且按照user_id升序排序 SELECT user_id from order_in...
Mysql
2021-11-09
0
200
题解 | #考试分数(五)#
看到了评论区的妙解,觉得太赞了,马一下! # 各个岗位中位数 # 首先计算出科目的人的个数以及分数排名 # 计算出排名和个数之间的关系。(科目的总人数+1)/2 与排名之间的关系为作差绝对值小于1 select g.id,g.job,g.score,g.row_num from (selec...
Mysql
2021-11-08
0
241
题解 | #考试分数(二)#
```# 运用窗口函数计算出不同岗位均分作为新的字段,筛选出各个岗位的高分即可 SELECT a.id,a.job,a.score from (SELECT id,job, score,avg(score) over(partition by job ) as avg_s from grade) a...
Mysql
2021-11-05
0
194
题解 | #牛客每个人最近的登录日期(六)#
# 首先,需要用户的信息是用户的名字,做题目的数量 # 接着,计算当前日期的累积量,sum()over()可以实现 select u.name,p.date ,sum(p.number)over(partition by u.name order by p.date)AS ps_num from ...
Mysql
2021-11-05
0
178
题解 | #异常的邮件概率#
# 首先 正常用户筛选,剔除掉黑名单 # send_id not in (select id from user where is_blacklist = 1) # receive_id not in n (select id from user where is_blacklist = 1) #...
Mysql
2021-11-01
0
338
题解 | #获取有奖金的员工相关信息。#
select a.emp_no,e.first_name,e.last_name,btype,salary ,case when btype = 1 then salary* 0.1 when btype = 2 then salary* 0.2 else salary*0...
Sqlite
2021-11-01
0
207
题解 | #获取有奖金的员工相关信息。#
select a.emp_no,e.first_name,e.last_name,btype,salary ,case when btype = 1 then salary* 0.1 when btype = 2 then salary* 0.2 else salary*0...
Sqlite
2021-10-29
0
212
题解 | #创建一个actor_name表#
create table actor_name (first_name varchar(45) not null ,last_name varchar(45) not null); insert into actor_name select fir...
Mysql
2021-10-28
0
277
首页
上一页
1
2
3
4
5
下一页
末页