排名

用户解题统计

过去一年提交了

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

错题集 数据思维刷题中答错的题目

模块 知识点 题目 你的答案 正确答案 操作
暂无错题,继续保持!

收藏

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

评论笔记

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

提交记录

提交日期 题目名称 提交代码
2026-11-18 德州扑克起手牌-最强起手牌KK+ 
select * from hand_permutations 
where concat(card1, card2) like '%A%K%' or
	concat(card1, card2) like '%K%K%' or
concat(card1, card2) like '%K%A%' or
concat(card1, card2) like '%A%A%'
2026-11-18 字符串与通配符(2)好多关键词做规则,可以使用rlike 
select
    case 
        when mch_nm like '%按摩保健休闲%' then '按摩保健休闲'
        when lower(mch_nm) rlike '.*(按摩|保健|休闲|spa|养生|会所).*' then '按摩、保健、休闲、养生、SPA、会所'
    end as reg_rules,
    count(distinct mch_nm) as mch_cnt
from
    cmb_usr_trx_rcd
where mch_nm like '%按摩保健休闲%'
   or lower(mch_nm) rlike '.*(按摩|保健|休闲|spa|养生|会所).*'
group by reg_rules
order by mch_cnt desc;
2026-11-18 字符串与通配符(2)好多关键词做规则,可以使用rlike 
select count(distinct mch_nm) as mch_cnt
from cmb_usr_trx_rcd 
where mch_nm like '%按摩%' or mch_nm like '%保健%' or mch_nm like '%休闲%' or mch_nm like '%养生%' or lower(mch_nm) like '%spa%' or mch_nm like '%会所%' 
union
select count(distinct mch_nm) as mch_cnt
from cmb_usr_trx_rcd 
where mch_nm like '%按摩保健休闲%'
2026-11-18 字符串与通配符(1)名称里面有特服,可以使用通配符 
select count(distinct mch_nm) as mch_cnt
from cmb_usr_trx_rcd 
where mch_nm like '%按摩保健休闲%'
2026-11-17 用户听歌习惯的时间分布 
select user_id, dayname(start_time) as day_of_week, count(distinct id) as listens_per_day
from listen_rcd
group by user_id, day_of_week
order by user_id, day_of_week
2026-11-17 用户听歌习惯的时间分布 
select user_id, dayname(start_time) as day_of_week, count(distinct id) as listens_per_day
from listen_rcd
group by user_id, day_of_week
order by user_id, dayname(start_time)
2026-11-17 用户听歌习惯的时间分布 
select user_id, dayname(start_time) as day_of_week, count(distinct id) as listens_per_day
from listen_rcd
group by user_id, dayname(start_time)
order by user_id, dayname(start_time)
2026-11-17 渣男腰子可真行,端午中秋干不停 
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')
2026-11-17 通勤、午休、临睡个时间段活跃人数分布 
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 else null end) as commute,
count(distinct case when time(login_time) between '11:30:00' and '14:00:00' then usr_id else null end) as lunch_break,
count(distinct case when time(login_time) between '22:30:00' and '23:59:59' or
time(login_time) between '00:00:00' and '01:00:00' then usr_id else null end) as bedtime
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')
2026-11-17 上月活跃用户数 
SELECT 
    COUNT(DISTINCT usr_id) AS active_users
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')
2026-11-17 上月活跃用户数 
SELECT 
    COUNT(DISTINCT usr_id) AS active_users
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');
2026-11-17 一线城市历年平均气温 
select year(dt) as Y,
	cast(sum(case when city = 'beijing' then tmp_h else 0 end) / sum(case when city = 'beijing' then 1 else 0 end) as decimal(10,2) )as '北京',
	cast(sum(case when city = 'shanghai' then tmp_h else 0 end) / sum(case when city = 'shanghai' then 1 else 0 end) as decimal(10,2) )as '上海',
	cast(sum(case when city = 'shenzhen' then tmp_h else 0 end) / sum(case when city = 'shenzhen' then 1 else 0 end) as decimal(10,2) )as '深圳',
	cast(sum(case when city = 'guangzhou' then tmp_h else 0 end) / sum(case when city = 'guangzhou' then 1 else 0 end) as decimal(10,2) )as '广州'
from weather_rcd_china 
where  year(dt) between 2011 and 2022 
group by year(dt)
2026-11-17 一线城市历年平均气温 
select year(dt) as Y,
	cast(sum(case when city = 'beijing' then tmp_h else 0 end) / sum(case when city = 'beijing' then 1 else 0 end) as decimal(10,2) )as '北京',
	cast(sum(case when city = 'shanghai' then tmp_h else 0 end) / sum(case when city = 'beijing' then 1 else 0 end) as decimal(10,2) )as '上海',
	cast(sum(case when city = 'shenzhen' then tmp_h else 0 end) / sum(case when city = 'beijing' then 1 else 0 end) as decimal(10,2) )as '深圳',
	cast(sum(case when city = 'guangzhou' then tmp_h else 0 end) / sum(case when city = 'beijing' then 1 else 0 end) as decimal(10,2) )as '广州'
from weather_rcd_china 
where dt between '2011-01-01' and '2022-12-31' and city in ('beijing', 'shanghai', 'guangzhou', 'shenzhen')
group by year(dt)
2026-11-17 冬季下雪天数 
select city, sum(case when con like '%雪%' then 1 else 0 end) as snowy_days
from weather_rcd_china
where month(dt) in (12,1,2)
group by city
order by snowy_days desc
2026-11-17 冬季下雪天数 
select city, count(*) as snowy_days
from weather_rcd_china
where con like '%雪%' and month(dt) in (12,1,2)
group by city
order by snowy_days desc
2026-11-17 冬季下雪天数 
select city, count(*)
from weather_rcd_china
where con like '%雪%' and month(dt) in (12,1,2)
group by city
2026-11-17 滴滴面试真题(2)打车订单呼叫应答时间 
SELECT 
    sum(TIMESTAMPDIFF(SECOND, call_time, grab_time))/count(1) AS avg_response_time_seconds
FROM 
    didi_order_rcd
WHERE 
    grab_time != '1970-01-01 00:00:00';
2026-11-17 条件过滤(3)Hour函数很给力,组合条件要仔细 
select * from cmb_usr_trx_rcd 
where usr_id='5201314520' and (date(trx_time) between '2024-09-01' and '2024-09-30') and (hour(trx_time) in (22,23,0,1,2,3,4,5))
2026-11-17 条件过滤(2)半夜活动有猫腻,Hour函数给给力 
select * from cmb_usr_trx_rcd 
where usr_id='5201314520' and (cast(trx_time as date) between '2024-09-01' and '2024-09-30') and (hour(trx_time) between 1 and 5)
2026-11-17 条件过滤(2)半夜活动有猫腻,Hour函数给给力 
select * from cmb_usr_trx_rcd 
where usr_id='5201314520' and (cast(trx_time as date) between '2024-09-01' and '2024-09-30') and (hour(trx_time) between 1 and 4)