stf666
stf666
全部文章
分类
归档
标签
去牛客网
登录
/
注册
stf666的博客
全部文章
(共55篇)
题解 | 商品销售总额分布
/*注意:脏数据包括空值和空字符串,二者概念不同,虽然题目未要求处理空值,但还是加上会严谨一些,空字符串要用单引号,聚合函数和group by 优先用group by,因为窗口函数可能会有重复计算,group by 直接去重了,更加简洁明了。 初--步--框--架 联表: from user_cli...
2025-10-20
0
28
题解 | 商品销售排名
/* select 是指选择支付方式,只要到了选择支付方式这一步,都视为该订单计入销售额; 完整的下单流程是select选择支付方式、order下单、start开始支付、failed支付失败、end支付结束*/ select t2.product_name ,t2.sales_total from(...
2025-10-20
0
30
题解 | 商品价格排名
select product_id ,product_name ,type ,price from( select product_id ,product_name ,type ,price ,dense_rank() over(partition by type order by price de...
2025-10-20
0
25
题解 | 用户购买次数前三
select uid ,count(step) as cnt from user_client_log where step = "order" group by uid order by uid,cnt desc limit 3 offset 0
2025-10-20
0
21
题解 | 下单最多的商品
select u.product_id ,count(u.product_id) as cnt from user_client_log u join product_info p on u.product_id = p.product_id where step = "order&qu...
2025-10-20
0
20
题解 | 统计快递从创建订单到发出间隔时长
select round(avg(timestampdiff(minute,create_time,out_time) / 60),3) as time from express_tb t1 join exp_action_tb t2 on t1.exp_number = t2.exp_number
2025-10-19
0
23
题解 | 统计快递运输时长
/*注意!!!timestampdiff()会截断小数部分,降低精确度!!!!*/ select t.exp_type ,round(avg(time1),1) as time from( select exp_type ,timestampdiff(minute,out_time,in_time)...
2025-10-19
1
25
题解 | 查询产生理赔费用的快递信息
/* 联表:from express_tb t1 join exp_cost_tb t2 on t1.exp_number = t2.exp_number 计数 :无 排序: order by claims_cost desc 筛选:where claims_cost is not null*/ s...
2025-10-19
0
23
题解 | 完成员工考核试卷突出的非领导员工
/*注意什么时候用聚合函数什么时候用where什么时候用having; 目标列名称是否需要修改----tag改成exam_tag 联表:from emp_info t1 join exam_record t3 on t1.emp_id = t3.emp_id join examination_inf...
2025-10-19
0
32
题解 | 淘宝店铺的实际销售额与客单价
/*注意:聚合函数里的列必须出现在group by里,注意用户需不需要去重,计算总销售额并不需要分组!!! 联表:from sales_tb s join goods_tb g on s.goods_id = g.goods_id 计数:每种商品销售额:sum(sales_num * goods_p...
2025-10-19
0
26
首页
上一页
1
2
3
4
5
6
下一页
末页