排名

用户解题统计

过去一年提交了

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

收藏

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

评论笔记

评论日期 题目名称 评论内容 站长评论
2025-09-27 不分类别的最火直播间 
select 
	t1.live_id,
    t2.live_nm,
    count(*) as "enter_cnt"
from ks_live_t1 t1
join ks_live_t2 t2 using(live_id) 
where t1.enter_time like "2021-09-12 23:%%:%%"
group by t1.live_id,t2.live_nm
order by enter_cnt desc
limit 5;
用like是否可行呢?是实际工作中哪种比较好
啥也没说

提交记录

提交日期 题目名称 提交代码
2025-10-09 查询播放量为0的歌手及其专辑 
select
	si.singer_id,
si.singer_name,
al.album_id,
al.album_name,
count(li.id) as play_count
from singer_info si
left join album_info al using(singer_id)
left join song_info so using(album_id)
left join listen_rcd li using(song_id)
group by si.singer_id, si.singer_name,al.album_id,al.album_name
having play_count=0;
2025-09-27 被收藏次数最多的商品 
select 
	gd.gd_id,
gd.gd_nm,
count(*) "fav_count"
from gd_inf gd
join xhs_fav_rcd fav on gd.gd_id=fav.mch_id
group by gd.gd_id
order by fav_count desc
limit 1;
2025-09-25 按歌手名字字符长度统计歌手个数 
select length(singer_name) "1",count(1) from singer_info group by 1;
2025-09-25 统计字符长度 
select 
	singer_name,
char_length(singer_name) "len"
from singer_info;
2025-09-25 歌手名字大写 
select upper(singer_name) "uppered_name" from singer_info;
2025-09-25 北京有雪的日子 
select dt,tmp_h,tmp_l,con 
from weather_rcd_china 
where city="beijing" and con like "%雪%";
2025-09-25 人数最多的学生姓氏 
select 
	 left(name,1) "surname",
 count(1) "cnt"
from students
group by surname
order by cnt desc
limit 5;
2025-09-25 人数最多的学生姓氏 
select 
	 left(name,1) "surname",
 count(1) "cnt"
from students
group by surname
order by cnt desc;
2025-09-24 多云天气天数 
select 
	city,
sum(case when con like "%多云%" then 1 else 0 end) as cloudy_days,
concat(cast((sum(case when con like "%多云%" then 1 else 0 end)/count(1))*100 as decimal(10,2)),"%") "p"
from weather_rcd_china
where year(dt)=2021
group by city
order by 3 desc;
2025-09-24 德州扑克起手牌- 手对 
select 
	* 
from hand_permutations
where left(card1,1)=left(card2,1);
2025-09-24 德州扑克起手牌- A花 
select * 
from hand_permutations
where 
	(card1 like "A%" or card2 like "A%") 
	and 
right(card1,1)=right(card2,1);
2025-09-24 德州扑克起手牌- A花 
select * 
from hand_permutations
where (card1 like "A" or card2 like "A") and left(card1,2)=left(card2,2);
2025-09-24 德州扑克起手牌- A花 
select * 
from hand_permutations
where left(card1,1)="A" and right(card2,2)!="A";
2025-09-24 德州扑克起手牌-最强起手牌KK+ 
select *
from hand_permutations
where 
	concat(card1,card2) like "%A%A%" or
concat(card1,card2) like "%A%K%" or
concat(card1,card2) like "%K%K%" or
concat(card1,card2) like "%K%A%" 
;
2025-09-24 字符串与通配符(2)好多关键词做规则,可以使用rlike 
select
	(case 
	when mch_nm like "%按摩保健休闲%" then "按摩保健休闲" 
		when mch_nm rlike ".*(按摩|保健|休闲|养生|SPA|会所).*" then "按摩、保健、休闲、养生、SPA、会所" end) as "reg_rules",
 count(distinct mch_nm) mch_cnt
from cmb_usr_trx_rcd
where mch_nm like "%按摩保健休闲%" or mch_nm rlike ".*(按摩|保健|休闲|养生|SPA|会所).*"
group by reg_rules
order by mch_cnt desc;
2025-09-22 字符串与通配符(1)名称里面有特服,可以使用通配符 
select count(distinct mch_nm) as mch_cnt
from cmb_usr_trx_rcd
where mch_nm like "%按摩保健休闲%";
2025-09-21 用户听歌习惯的时间分布 
select 
	user_id,
dayname(start_time) "day_of_week",
count(1) "listens_per_day"
from listen_rcd
group by user_id,day_of_week
order by user_id,day_of_week;
2025-09-21 渣男腰子可真行,端午中秋干不停 
select * 
from cmb_usr_trx_rcd
where 
	usr_id="5201314520" and 
(date(trx_time) between "2024-06-08" and "2024-06-10" or
date(trx_time) between "2024-09-15" and "2024-09-17");
2025-09-21 渣男腰子可真行,端午中秋干不停 
select * 
from cmb_usr_trx_rcd
where 
	usr_id="5201314520" and 
date(trx_time) between "2024-06-08" and "2024-06-10" or
date(trx_time) between "2024-09-15" and "2024-09-17";
2025-09-21 通勤、午休、临睡个时间段活跃人数分布 
select 
	count(distinct case 
when time(login_time) between "07:30:00" and "09:30:00" or time(login_time) between "18:30:00" and "20:30:00" then usr_id end) as "通勤",
count(distinct case 
when time(login_time) between "11:30:00" and "14:00:00" then usr_id end) as "午休",
count(distinct case 
when time(login_time) between "22:30:00" and "23:59:59" then usr_id
when time(login_time) between "00:00:00" and "01:00:00" then usr_id end) as "临睡"
from user_login_log
where 
	login_time>=date_format(date_sub(curdate(),interval 1 month),"%y-%m-01 00:00:00") and
login_time<date_format(curdate(),"%y-%m-01 00:00:00");