排名

用户解题统计

过去一年提交了

勋章 ①金银铜:在竞赛中获得第一二三名;②好习惯:自然月10天提交;③里程碑:解决1/2/5/10/20/50/100/200题;④每周打卡挑战:完成每周5题,每年1月1日清零。

收藏

收藏日期 题目名称 解决状态
没有收藏的题目。

评论笔记

评论日期 题目名称 评论内容 站长评论
没有评论过的题目。

提交记录

提交日期 题目名称 提交代码
2026-04-22 各商品漏斗转化率 
select
	m.prd_id, m.prd_nm,
sum(if_snd) as exposure_count,
sum(if_vw) as view_count,
sum(if_cart) as cart_count,
sum(if_buy) as buy_count,
round(sum(if_vw)*100.0/sum(if_snd),2) as view_rate,
round(sum(if_cart)*100.0/sum(if_snd),2) as view_rate,
round(sum(if_buy)*100.0/sum(if_snd),2) as view_rate
from tb_pg_act_rcd r
join tb_prd_map m on r.prd_id = m.prd_id
group by
	m.prd_id, m.prd_nm
2026-04-22 每个商品的用户性别分布 
select
	m.prd_id, m.prd_nm,
count(distinct case when gdr = 'M' then r.cust_uid end) as male_count,
count(distinct case when gdr = 'F' then r.cust_uid end) as female_count,
count(distinct r.cust_uid) as total_count
from tb_pg_act_rcd r
join tb_cst_bas_inf i on r.cust_uid = i.cust_uid
join tb_prd_map m on r.prd_id = m.prd_id
where r.if_buy = 1
group by
	m.prd_id, m.prd_nm
order by
	1
2026-04-21 先收藏后购买的用户数 
with user_info as (
select
	distinct 
r1.cust_uid,
r1.mch_id,
r1.fav_tm,
r2.pchs_tm
from xhs_fav_rcd r1
left join xhs_pchs_rcd r2 
on r1.cust_uid = r2.cust_uid and r1.mch_id = r2.mch_id and r1.fav_tm <= r2.pchs_tm
)
select
	count(distinct cust_uid) as cnt
from
	user_info
where
	pchs_tm is not null
2026-04-21 给商品打四类标签(列) 
with fav_info as (
select
	distinct g.gd_id,
	g.gd_nm,
	g.gd_typ,
	case when r1.fav_trq is null then '不收藏' else '收藏' end as fav
from gd_inf g
left join xhs_fav_rcd r1 on g.gd_id = r1.mch_id
)
select
	f.gd_id,
	f.gd_nm,
	f.gd_typ,
max(case when f.fav = '收藏' and r2.pch_trq is not null then 1 else 0 end) as both_collected_and_purchased,
max(case when f.fav = '收藏' and r2.pch_trq is null then 1 else 0 end) as only_collected_not_purchased,
 	max(case when f.fav = '不收藏' and r2.pch_trq is not null then 1 else 0 end) as only_purchased_not_collected,
max(case when f.fav = '不收藏' and r2.pch_trq is null then 0 else 0 end) as neither_collected_nor_purchased,
count(distinct pch_trq) as purchase_count
from
	fav_info f
left join 
	xhs_pchs_rcd r2 on f.gd_id = r2.mch_id
group by
	f.gd_id, f.gd_nm, f.gd_typ
order by
	4 desc
2026-04-20 给商品打四类标签(行) 
with fav_info as (
select
	distinct g.gd_id,
g.gd_nm,
g.gd_typ,
case when r1.fav_trq is null then '不收藏' else '收藏' end as fav
from gd_inf g
left join xhs_fav_rcd r1 on g.gd_id = r1.mch_id
)
select
	distinct f.gd_id,
f.gd_nm,
f.gd_typ,
case when f.fav = '收藏' and r2.pch_trq is not null then '收藏且购买'
	 when f.fav = '收藏' and r2.pch_trq is null then '收藏不购买'
 when f.fav = '不收藏' and r2.pch_trq is not null then '购买不收藏'
 when f.fav = '不收藏' and r2.pch_trq is null then '不收藏不购买'
	end as category
from
	fav_info f
left join xhs_pchs_rcd r2 on f.gd_id = r2.mch_id
2026-04-20 查询所有正在进行中的促销活动 
select
	* 
from 
	promotion_events
where
	'2025-03-08' between start_time and end_time
and	is_active = 1
2026-04-20 查询所有正在进行中的促销活动 
select
	* 
from 
	promotion_events
where
	'2025-03-08' between start_time and end_time
2026-04-20 能组成直角三角形的线段 
SELECT *
FROM numbers_for_fun
WHERE (ABS(a) + ABS(b) > ABS(c) AND ABS(c) + ABS(b) > ABS(a) AND ABS(a) + ABS(c) > ABS(b))
AND (ABS(a)*ABS(a) + ABS(b)*ABS(b) = ABS(c)*ABS(c) OR
 ABS(a)*ABS(a) + ABS(c)*ABS(c) = ABS(b)*ABS(b) OR
 ABS(b)*ABS(b) + ABS(c)*ABS(c) = ABS(a)*ABS(a))
ORDER BY id;
2026-04-20 能组成钝角三角形的线段 
SELECT *
FROM numbers_for_fun
WHERE (ABS(a) + ABS(b) > ABS(c) AND ABS(c) + ABS(b) > ABS(a) AND ABS(a) + ABS(c) > ABS(b))
AND (ABS(a)*ABS(a) + ABS(b)*ABS(b) < ABS(c)*ABS(c) OR
 ABS(a)*ABS(a) + ABS(c)*ABS(c) < ABS(b)*ABS(b) OR
 ABS(b)*ABS(b) + ABS(c)*ABS(c) < ABS(a)*ABS(a))
ORDER BY id
2026-04-20 能组成直角三角形的线段 
SELECT *
FROM numbers_for_fun
WHERE (ABS(a)*ABS(a) + ABS(b)*ABS(b) = ABS(c)*ABS(c) OR
 ABS(a)*ABS(a) + ABS(c)*ABS(c) = ABS(b)*ABS(b) OR
 ABS(b)*ABS(b) + ABS(c)*ABS(c) = ABS(a)*ABS(a))
ORDER BY id;
2026-04-20 能组成直角三角形的线段 
SELECT *
FROM numbers_for_fun
WHERE ABS(a) > 0 AND ABS(b) > 0 AND ABS(c) > 0
AND (ABS(a)*ABS(a) + ABS(b)*ABS(b) = ABS(c)*ABS(c) OR
 ABS(a)*ABS(a) + ABS(c)*ABS(c) = ABS(b)*ABS(b) OR
 ABS(b)*ABS(b) + ABS(c)*ABS(c) = ABS(a)*ABS(a))
ORDER BY id;
2026-04-20 能组成直角三角形的线段 
select
	* 
from 
	numbers_for_fun
where
	case 
	when abs(a) >= abs(b) and abs(a) >= abs(c) then pow(abs(a),2) = pow(abs(b),2) + pow(abs(c),2)
when abs(b) >= abs(a) and abs(b) >= abs(c) then pow(abs(b),2) = pow(abs(a),2) + pow(abs(c),2)
else pow(abs(c),2) = pow(abs(a),2) + pow(abs(b),2)
end
and a*b*c <> 0
order by id asc
2026-04-20 能组成直角三角形的线段 
select
	* 
from 
	numbers_for_fun
where
	case 
	when abs(a) >= abs(b) and abs(a) >= abs(c) then pow(abs(a),2) = pow(abs(b),2) + pow(abs(c),2)
when abs(b) >= abs(a) and abs(b) >= abs(c) then pow(abs(b),2) = pow(abs(a),2) + pow(abs(c),2)
else pow(abs(c),2) = pow(abs(a),2) + pow(abs(b),2)
end
order by id asc
2026-04-20 能组成直角三角形的线段 
select * 
from numbers_for_fun
2026-04-20 能组成三角形的线段 
select 
	* 
from 
	numbers_for_fun
where
	abs(a) + abs(b) > abs(c)
and	abs(a) + abs(c) > abs(b)
and abs(b) + abs(c) > abs(a)
order by
	id
2026-04-20 近1个月最热短视频 
with video_info as (
select
	ks1.video_id,
ks1.title,
count(uid) as view_count,
sum(if_like) as like_count,
sum(if_retweet) as retweet_count,
sum(if_fav) as fav_count
from ks_video_inf ks1
join ks_video_wat_log ks2
on ks1.video_id = ks2.video_id
where
	ks2.start_time >= date_sub(curdate(), interval 1 month)
group by
	ks1.video_id, ks1.title
)
select
	video_id,
title,
view_count,
like_count,
retweet_count,
fav_count,
(like_count + retweet_count + fav_count) as total_interactions
from
	video_info
order by
	7 desc
limit
	3
2026-04-20 整体的点击率 
select
	count(r1.search_tm) as total_searches,
count(r2.click_page_id) as total_clicks,
round(count(r2.click_page_id)*100.0 / count(r1.search_tm),2) as click_rate
from jx_query_rcd r1
left join jx_click_rcd r2 on r1.session_id = r2.session_id
2026-04-20 整体的点击率 
select
	count(r1.search_tm) as total_searches,
count(r2.click_page_id) as total_clicks,
round(count(r2.click_page_id)*100.0 / count(r1.usr_id),2) as click_rate
from jx_query_rcd r1
left join jx_click_rcd r2 on r1.session_id = r2.session_id
2026-04-20 整体的点击率 
select
	count(r1.usr_id) as total_searches,
count(r2.click_page_id) as total_clicks,
round(count(r2.click_page_id)*100.0 / count(r1.usr_id),2) as click_rate
from jx_query_rcd r1
left join jx_click_rcd r2 on r1.session_id = r2.session_id
2026-04-20 分关键词的搜索UV转化率 
select
	r1.key_word,
count(distinct r1.usr_id) as total_search_users,
count(distinct r2.usr_id) as users_reached_users,
round(count(distinct r2.usr_id)*100.0 / count(distinct r1.usr_id),2) as uv_conversion_rate
from jx_query_rcd r1
left join jx_click_rcd r2 on r1.session_id = r2.session_id
group by
	r1.key_word
order by 
	4 desc
limit
	10