排名

用户解题统计

过去一年提交了

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

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

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

收藏

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

评论笔记

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

提交记录

提交日期 题目名称 提交代码
2026-05-18 每年在深交所上市的银行有多少家 
with basic as (select year(list_date) as dt,
case when ts_code like '%SZ' then 1 else 0 end as co 
from stock_info
where industry = '银行')
select dt,sum(co) as cnt
from basic
group by dt
having cnt >0
order by dt
2026-05-18 每年在深交所上市的银行有多少家 
with basic as (select year(list_date) as dt,
case when ts_code like '%SZ' then 1 else 0 end as co 
from stock_info
where industry = '银行')
select dt,sum(co) as cnt
from basic
group by dt
order by dt
2026-05-18 每年在深交所上市的银行有多少家 
with basic as (select year(list_date) as dt,
case when ts_code like '%SZ' then 1 else 0 end as co 
from stock_info
where industry = '银行')
select dt,count(co) as cnt
from basic
group by dt
order by dt
2026-05-18 每年在深交所上市的银行有多少家 
with basic as (select year(list_date) as dt,
case when ts_code like '%SZ' then 1 else 0 end as co 
from stock_info)
select dt,sum(co) as cnt
from basic
group by dt
order by dt
2026-05-18 找出所有以酒店为起点或终点的类别组合的最热门路线 
with t as (select cust_uid,start_loc,l1.loc_ctg as locs,end_loc,l2.loc_ctg as loce
from didi_sht_rcd as dd 
join loc_nm_ctgas l1 
on dd.start_loc = l1.loc_nm
join loc_nm_ctg as l2 
on dd.end_loc = l2.loc_nm
where l1.loc_ctg = "酒店" or l2.loc_ctg = "酒店"),
ranked as (select start_loc,locs,end_loc,loce,count(*) as trip,
row_number()over(partition by locs,loce order by count(*) desc) as t
from t 
group by start_loc,locs,end_loc,loce
order by trip desc)
select start_loc,end_loc,locs,loce,trip
from ranked
where t = 1
2026-05-18 找出所有以酒店为起点或终点的类别组合的最热门路线 
WITH hotel_routes AS (
    SELECT r.start_loc, r.end_loc, l_start.loc_ctg AS start_ctg, l_end.loc_ctg AS end_ctg, COUNT(*) AS trip_count
    FROM didi_sht_rcd r
    JOIN loc_nm_ctg l_start ON r.start_loc = l_start.loc_nm
    JOIN loc_nm_ctg l_end ON r.end_loc = l_end.loc_nm
    WHERE l_start.loc_ctg = '酒店' OR l_end.loc_ctg = '酒店'
    GROUP BY r.start_loc, r.end_loc, l_start.loc_ctg, l_end.loc_ctg
),
ranked_routes AS (
    SELECT start_loc, end_loc, start_ctg, end_ctg, trip_count,
           ROW_NUMBER() OVER (PARTITION BY start_ctg, end_ctg ORDER BY trip_count DESC) AS route_rank
    FROM hotel_routes
)
SELECT start_loc, end_loc, start_ctg, end_ctg, trip_count
FROM ranked_routes
WHERE route_rank = 1
ORDER BY trip_count DESC;
2026-05-18 找出所有以酒店为起点或终点的类别组合的最热门路线 
with t as (
select 
cust_uid,
start_loc,
l1.loc_ctg as locs,
end_loc,
l2.loc_ctg as loce 
from didi_sht_rcd as dd 
join loc_nm_ctg as l1 
on dd.start_loc = l1.loc_nm
join loc_nm_ctg as l2 
on dd.end_loc = l2.loc_nm
where l1.loc_ctg = '酒店' or l2.loc_ctg = '酒店'
),
ranked as (
select 
start_loc,
locs,
end_loc,
loce,
count(*) as trip,
row_number() over(partition by locs, loce order by count(*) desc) as ranking
from t 
group by start_loc, locs, end_loc, loce
)
select 
start_loc,
locs,
end_loc,
loce,
trip
from ranked
where ranking = 1
order by trip desc;
2026-05-18 找出所有以酒店为起点或终点的类别组合的最热门路线 
with t as (select cust_uid,start_loc,l1.loc_ctg as locs,end_loc,l2.loc_ctg as loce
from didi_sht_rcd as dd 
join loc_nm_ctgas l1 
on dd.start_loc = l1.loc_nm
join loc_nm_ctg as l2 
on dd.end_loc = l2.loc_nm
where l1.loc_ctg = "酒店" or l2.loc_ctg = "酒店"),
ranked as (select start_loc,locs,end_loc,loce,count(*) as trip,
row_number()over(partition by locs,loce order by count(*) desc) as t
from t 
group by start_loc,locs,end_loc,loce)
select start_loc,locs,end_loc,loce,trip
from ranked
where t = 1
order by trip desc
2026-05-18 找出所有以酒店为起点或终点的类别组合的最热门路线 
with t as (select cust_uid,start_loc,l1.loc_ctg as locs,end_loc,l2.loc_ctg as loce
from didi_sht_rcd as dd 
join loc_nm_ctgas l1 
on dd.start_loc = l1.loc_nm
join loc_nm_ctg as l2 
on dd.end_loc = l2.loc_nm
where l1.loc_ctg = "酒店" or l2.loc_ctg = "酒店"),
ranked as (select start_loc,locs,end_loc,loce,count(*) as trip,
row_number()over(partition by locs,loce order by count(*) desc) as t
from t 
group by start_loc,locs,end_loc,loce)
select start_loc,locs,end_loc,loce,trip
from ranked
where t = 1
2026-05-14 窗口函数(4)越来越喜欢召妓,窗口函数用累计(2) 
with month_sequence as (
    select 
        date_format(dv.date_value, '%Y-%m') as trx_mon
    from 
        date_table dv
    where 
        year(dv.date_value) = 2023
        and month(dv.date_value) between 1 and 12
    group by date_format(dv.date_value, '%Y-%m')
),
monthly_trx as (
    select 
        date_format(t.trx_time, '%Y-%m') as trx_mon, 
        sum(t.trx_amt) as monthly_trx_amt
    from 
        cmb_usr_trx_rcd t
    join 
        cmb_mch_typ m on t.mch_nm = m.mch_nm
    where 
        t.usr_id = 5201314520 
        and m.mch_typ = '休闲娱乐'
        and year(t.trx_time) = 2023
    group by 
        trx_mon
),
combined_trx as (
    select 
        ms.trx_mon, 
        coalesce(mt.monthly_trx_amt, 0) as monthly_trx_amt
    from 
        month_sequence ms
    left join 
        monthly_trx mt on ms.trx_mon = mt.trx_mon
)
    select 
        trx_mon, 
        sum(monthly_trx_amt) over (order by trx_mon) as cumulative_trx_amt
    from 
        combined_trx
2026-05-14 窗口函数(4)越来越喜欢召妓,窗口函数用累计(2) 
with tm as (
select date_format(date_value,'%Y-%m') as dt
from date_table
where year(date_value) = 2023
group by date_format(date_value,'%Y-%m')
order by dt
),
bs as (
select 
date_format(trx_time,'%Y-%m') as dt,
usr_id,
mch_nm,
coalesce(trx_amt,0) as trx_amt
from cmb_usr_trx_rcd
where usr_id = '5201314520'
),
diedai as (
select 
tm.dt,
sum(coalesce(trx_amt,0)) as t
from tm
left join bs on tm.dt = bs.dt
left join cmb_mch_typ as typ 
on bs.mch_nm = typ.mch_nm 
and typ.mch_typ = '休闲娱乐'
group by tm.dt
)
select 
dt,
sum(t) over(order by dt) as trx_amt
from diedai
order by dt;
2026-05-14 窗口函数(4)越来越喜欢召妓,窗口函数用累计(2) 
with tm as (select date_format(date_value,'%Y-%m') as dt
from date_table
where year(date_value) = 2023
group by date_format(date_value,'%Y-%m')
order by dt),
bs as (select date_format(trx_time,'%Y-%m') as dt,usr_id,mch_nm,coalesce(trx_amt,0) as trx_amt
from cmb_usr_trx_rcd),
diedai as (select tm.dt,sum(coalesce(trx_amt,0)) as t
from tm
left join bs
on tm.dt = bs.dt
left join cmb_mch_typ as typ
on bs.mch_nm = typ.mch_nm
where mch_typ = '休闲娱乐' and usr_id = '5201314520'
group by tm.dt)
select dt,sum(t) over(order by dt) as trx_amt
from diedai
order by dt
2026-05-14 窗口函数(4)越来越喜欢召妓,窗口函数用累计(2) 
with tm as (select date_format(date_value,'%Y-%m') as dt
from date_table
where year(date_value) = 2023
group by date_format(date_value,'%Y-%m')
order by dt),
bs as (select date_format(trx_time,'%Y-%m') as dt,usr_id,mch_nm,trx_amt
from cmb_usr_trx_rcd),
diedai as (select tm.dt,sum(trx_amt) as t
from tm
left join bs
on tm.dt = bs.dt
left join cmb_mch_typ as typ
on bs.mch_nm = typ.mch_nm
where mch_typ = '休闲娱乐' and usr_id = '5201314520'
group by tm.dt)
select dt,sum(t) over(order by dt) as trx_amt
from diedai
order by dt
2026-05-14 窗口函数(4)越来越喜欢召妓,窗口函数用累计(2) 
with tm as (select date_format(date_value,'%Y-%m') as dt
from date_table
where year(date_value) = 2023
group by date_format(date_value,'%Y-%m')
order by dt),
bs as (select date_format(trx_time,'%Y-%m') as dt,usr_id,mch_nm,trx_amt
from cmb_usr_trx_rcd),
diedai as (select tm.dt,sum(trx_amt) as t
from tm
left join bs
on tm.dt = bs.dt
left join cmb_mch_typ as typ
on bs.mch_nm = typ.mch_nm
where mch_typ = '休闲娱乐' and usr_id = '5201314520'
group by tm.dt)
select dt,sum(t) over(order by dt) as trx_amt
from diedai
2026-05-13 窗口函数(4)越来越喜欢召妓,窗口函数用累计(2) 
with yy as (select date_format(date_value,"%Y-%m") as dt
from date_table
where year(date_value) = 2023
group by date_format(date_value,"%Y-%m")),
basic as (
select date_format(trx_time,"%Y-%m") as dt,usr_id,mch_nm,trx_amt
 from cmb_usr_trx_rcd
 )
 select yy.dt,sum(trx_amt) as trx_amt
 from yy
 left join basic on yy.dt= basic.dt
 left join cmb_mch_typ as typ on typ.mch_nm = basic.mch_nm
 where usr_id = '5201314520' and typ.mch_typ = '休闲娱乐'
 group by yy.dt
 order by yy.dt
2026-05-11 分类别的最火直播间 
WITH LiveRoomStats AS (
    SELECT 
        t1.live_id,
        t2.live_nm,
        t2.live_type,
        COUNT(*) AS enter_cnt,
        ROW_NUMBER() OVER (PARTITION BY t2.live_type ORDER BY COUNT(*) DESC) AS rnk
    FROM 
        ks_live_t1 t1
    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, t2.live_type
)
SELECT 
    live_id,
    live_nm,
    live_type,
    enter_cnt
FROM 
    LiveRoomStats
WHERE 
    rnk <= 1
ORDER BY 
    live_id;
2026-05-11 滴滴面试真题(3)UTC转化后的本地时间呼叫高峰期 
with lt as (select date_add(call_time,interval -3 hour) as local_t,order_id
from didi_order_rcd)
select hour(local_t),count(order_id) as cnt
from lt
group by hour(local_t)
order by count(order_id)desc
2026-05-11 滴滴面试真题(3)UTC转化后的本地时间呼叫高峰期 
with lt as (select date_add(call_time,interval 3 hour) as local_t,order_id
from didi_order_rcd)
select hour(local_t),count(order_id) as cnt
from lt
group by hour(local_t)
order by count(order_id)desc
2026-05-11 滴滴面试真题(1)-打车订单应答率 
selectcount(1) as total_orders,
sum(case when grab_time= '1970-01-01 00:00:00' then 0 else 1 end) as answered_orders,
concat(round(sum(case when grab_time= '1970-01-01 00:00:00' then 0 else 1 end) /count(1)*100,2),'%')
from didi_order_rcd
where date(call_time)= '2021-05-03'
2026-05-11 窗口函数(1)年度前三和每月前三,搞懂排序窗口函数 
with y_cmb as (select mch_nm,sum(trx_amt) as sum_trx_amt
from cmb_usr_trx_rcd
where usr_id = '5201314520' and year(trx_time) = 2024
group by mch_nm
order by sum_trx_amt desc
 limit 3 ),
monthly_top_merchants as (
 select date_format(trx_time,'%Y-%m') as trx_mon,mch_nm,sum(trx_amt) as sum_trx_amt,
 row_number()over(partition by date_format(trx_time,'%Y-%m') order by sum(trx_amt) desc) as ranking
 from cmb_usr_trx_rcd
 where usr_id = '5201314520' and year(trx_time) = 2024
 group by   trx_mon, mch_nm),
 filter_end as (
 selecttrx_mon,mch_nm,sum_trx_amt
 from monthly_top_merchants
 where ranking<=3
 )
select 
    '2024' as trx_mon, 
    mch_nm, 
    sum_trx_amt
from 
    y_cmb 
union all
select 
    trx_mon, 
    mch_nm, 
    sum_trx_amt
from 
   filter_end
order by 
    trx_mon, 
    sum_trx_amt desc;