排名

用户解题统计

过去一年提交了

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

收藏

评论笔记

评论日期 题目名称 评论内容 站长评论
2025-09-17 分组与聚合函数(5)五花八门的项目,其实都有固定套路(2) 
select 
trx_amt,
count(1) as total_trx_cnt,
count(distinct usr_id) as unique_usr_cnt,
count(1)/count(distinct usr_id) as avg_trx_per_user
from cmb_usr_trx_rcd 
where date_format(trx_time,'%Y-%m') between '2023-01' and '2024-06' 
and mch_nm='红玫瑰按摩保健休闲'
group by trx_amt
order by avg_trx_per_user desc
limit 5
啥也没说

提交记录

提交日期 题目名称 提交代码
2025-09-21 用户听歌习惯的时间分布 
select user_id,DAYNAME(start_time) day_of_week,count(1) as listens_per_day from listen_rcd
group by user_id,day_of_week
 order by user_id
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'))
 order by trx_time
2025-09-21 每年在深交所上市的银行有多少家 
select year(list_date) Y,count(1) as cnt from stock_info 
where industry='银行' and right(ts_code,2)='SZ'
group by year(list_date)
 order byY
2025-09-21 销售金额前10的商品信息 
select goods_id as oods_id,	sum(order_gmv) as total_gmv from order_info 
where date(order_time) = '2024-09-10'
group by goods_id
order by total_gmv desc
 limit 10
2025-09-21 销售金额前10的商品信息 
select goods_id as oods_id,	sum(order_gmv) as total_gmv from order_info 
where date(order_time) = '2024-09-10'
group by goods_id
order by total_gmv desc
2025-09-21 绘制小时进入人数曲线 
select lpad(hour(enter_time), 2, '0') hour_entered, count(1) as enter_count
from ks_live_t1 
group by hour_entered
order by hour_entered
2025-09-21 绘制小时进入人数曲线 
select hour(enter_time) hour_entered, count(1) as enter_count
from ks_live_t1 
group by hour_entered
order by hour_entered
2025-09-21 销售金额前10的商品信息 
select 
goods_id as oods_id,
sum(order_gmv) as total_gmv 
from order_info 
where date(order_time)='2024-09-10'
group by goods_id
order by total_gmv desc
 limit 10
2025-09-20 子查询(1)玩的最嗨那天在做甚?要用Where子查询 
select * from cmb_usr_trx_rcd
where year(trx_time) = 2024
and usr_id = 5201314520
order by trx_amt desc
limit 1
2025-09-20 特定歌曲的播放记录 
select * from listen_rcd 
where 
 date(start_time) between'2023-12-10' and '2023-12-31'
 and song_id=13
 order by start_time
2025-09-20 城市平均最高气温 
select 
city,
cast(avg(replace(tmp_h,'℃','')) as decimal(4,2)) as avg_tmp_h
from weather_rcd_china
where year(dt)=2021
group by city
 order by avg_tmp_h desc
2025-09-20 不分类别的最火直播间 
select     
t2.live_id,
t2.live_nm,
COUNT(*) AS enter_cnt
from ks_live_t1 t1
 inner join ks_live_t2 t2
 on t1.live_id = t2.live_id
 where 
DATE_FORMAT(t1.enter_time, '%Y-%m-%d %H') = '2021-09-12 23'
group by
	t1.live_id, t2.live_nm
ORDER BY 
    enter_cnt DESC
LIMIT 5;
2025-09-20 表连接(2)渣男去过我对象没去过,那就用LeftJoin 
select 
asshole_tried,trx_cnt,b.mch_nm
from (
select distinct mch_nm as asshole_tried ,count(1) as trx_cntfrom cmb_usr_trx_rcd 
where year(trx_time) in (2023,2024) and usr_id = 5201314520
group by mch_nm 
having count(1)>=20
 ) a 
 left join
 (
 select distinct mch_nm from cmb_usr_trx_rcd 
where year(trx_time) in (2023,2024) and usr_id = 5211314521
 ) b
 on a.asshole_tried=b.mch_nm
 order by trx_cnt desc
2025-09-19 多云天气天数 
select 
city,
sum(if(con like '%多云%',1,0)) as cloudy_days,
concat(cast(sum(if(con like '%多云%',1,0))/count(1)*100 AS DECIMAL(10,2)),'%') as p
from weather_rcd_china 
where year(dt)=2021
group by city
order by p desc
2025-09-19 德州扑克起手牌-同花 
select 
sum(case when right(card1,1)=right(card2,1) then 1 else 0 end)/2 as cnt
, count(1)/2 as ttl_cnt 
,cast(sum(case when right(card1,1)=right(card2,1) then 1 else 0 end)/count(1) AS DECIMAL(4,3)) as p 
from hand_permutations
2025-09-19 德州扑克起手牌- 手对 
select * from hand_permutations 
where right(card1,1)!=right(card2,1)
 and left(card1,1)=left(card2,1)
 order by id
2025-09-19 德州扑克起手牌- A花 
select * from hand_permutations 
where
right(card1, 1) = right(card2, 1)
and (card1 like 'A%'
or card2 like 'A%')
 order by id
2025-09-19 德州扑克起手牌- A花 
select * from hand_permutations 
where card1 like 'A%'
or card2 like 'A%'
2025-09-19 德州扑克起手牌-最强起手牌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%'
 order by id;
2025-09-19 表连接(1)你们难道都去过?那就试试用InnerJoin 
select a.* from 
(select distinct mch_nm from cmb_usr_trx_rcd 
where usr_id = 5201314520
and year(trx_time)=2024) a
inner join 
(selectdistinct mch_nm from cmb_usr_trx_rcd 
where usr_id = 5211314521
and year(trx_time)=2024) b
on a.mch_nm = b.mch_nm
order by mch_nm desc