排名

用户解题统计

过去一年提交了

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

收藏

评论笔记

评论日期 题目名称 评论内容 站长评论
2025-05-17 字符串与通配符(2)好多关键词做规则,可以使用rlike 
好的,非常感谢!!!
啥也没说
2025-05-14 字符串与通配符(2)好多关键词做规则,可以使用rlike 
select '按摩、保健、休闲、养生、SPA、会所' as reg_rules,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 upper(mch_nm) like '%SPA%'
or mch_nm like '%会所%'
union 
select '按摩保健休闲'as reg_rules,count(distinct mch_nm) as mch_cnt
from cmb_usr_trx_rcd
where mch_nm like '%按摩保健休闲%'####为什么这个第一项返回的是30 多一个呢,笨办法一个一个like跟rlike咋不一样 是有什么细微的区别吗?
“按摩保健休闲”在你的第一段sql里,被算了一遍了。

where mch_nm like '%按摩%'这个筛选条件已经把“按摩保健休闲”计算一遍了。
2025-05-11 大于J小于K的手牌 
这道题答案真的没问题吗?card1和2的类型是字符串,但也不是简单的字母不可以直接比较吧?而且牌序J<Q<K,但是字母的顺序是J<K<Q冲突了
这道题就是为了告诉你,字符串也是可以比较的,比较的逻辑就是字符编码的位置。你把下面这段代码丢给大模型问问是什么意思就明白啦 select ord('J'),ord('K'),ord('Q')

提交记录

提交日期 题目名称 提交代码
2025-05-22 不分类别的最火直播间 
select k1.live_id,live_nm,count(*) enter_cnt
from ks_live_t1 k1
join ks_live_t2 k2
on k1.live_id=k2.live_id
where enter_time between '2021-09-12 23:00:00' and '2021-09-12 23:59:59'
group by k1.live_id,live_nm
order by enter_cnt desc
limit 5
2025-05-17 字符串与通配符(2)好多关键词做规则,可以使用rlike 
select
    case 
        when mch_nm like '%按摩保健休闲%' then '按摩保健休闲'
        when lower(mch_nm) regexp '按摩|保健|休闲|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) regexp '按摩|保健|休闲|spa|养生|会所'
group by reg_rules
order by mch_cnt desc;
2025-05-14 按歌手名字字符长度统计歌手个数 
select length(singer_name),count(singer_name)
from singer_info
group by length(singer_name)
2025-05-14 统计字符长度 
select singer_name,char_length(singer_name) len
from singer_info
2025-05-14 歌手名字大写 
select upper(singer_name) from singer_info
2025-05-14 北京有雪的日子 
select dt,tmp_h,tmp_l,con from weather_rcd_china
where con like '%雪%'
and city ='beijing'
2025-05-14 北京有雪的日子 
select dt,tmp_h,tmp_l,con,wnd from weather_rcd_china
where con like '%雪%'
and city ='beijing'
2025-05-14 北京有雪的日子 
select dt,tmp_h,tmp_l,con,wnd from weather_rcd_china
where con like '雪'
and city ='beijing'
2025-05-14 人数最多的学生姓氏 
select left(name,1) as surname,count(*) as cnt from students
group by surname
order by cnt desc
limit 5
2025-05-14 多云天气天数 
select city,count(dt) as cloudy_days,concat(round(count(dt)/365*100,2),'%') as p from weather_rcd_china
where year(dt)=2021
and con like '%多云%'
group by city
order by p desc
2025-05-14 德州扑克起手牌- 手对 
select * from hand_permutations
where left(card1,1)=left(card2,1)
2025-05-14 德州扑克起手牌- A花 
select * from hand_permutations
where right(card1,1)=right(card2,1)
and
(card1 like 'A%' or card2 like 'A%')
order by id
2025-05-14 德州扑克起手牌-最强起手牌KK+ 
select * from hand_permutations
where concat(card1,card2) like'%A%K%'
or concat(card1,card2) like'%A%A%'
or concat(card1,card2) like'%K%A%'
or concat(card1,card2) like'%K%K%'
order by id
2025-05-14 字符串与通配符(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;
2025-05-14 字符串与通配符(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 lower(mch_nm) rlike '.*(按摩|保健|休闲|spa|养生|会所).*'
group by reg_rules
order by mch_cnt desc;
2025-05-14 字符串与通配符(2)好多关键词做规则,可以使用rlike 
select '按摩、保健、休闲、养生、SPA、会所' as reg_rules,count(distinct mch_nm)
from cmb_usr_trx_rcd
where mch_nm like '%按摩%'
or mch_nm like '%保健%'
or mch_nm like '%休闲%'
or mch_nm like '%养生%'
or mch_nm like '%SPA%'
or mch_nm like '%会所%'
union 
select '按摩保健休闲'as reg_rules,count(distinct mch_nm)
from cmb_usr_trx_rcd
where mch_nm like '%按摩保健休闲%'
2025-05-14 字符串与通配符(1)名称里面有特服,可以使用通配符 
select count(distinct mch_nm) as mch_cnt from cmb_usr_trx_rcd
where mch_nm like '%按摩保健休闲%'
2025-05-14 用户听歌习惯的时间分布 
select user_id,
dayname(start_time)
as day_of_week,
count(*) as listens_per_day
from listen_rcd
group by user_id,day_of_week
order by user_id,day_of_week
2025-05-14 用户听歌习惯的时间分布 
select user_id,
case when dayofweek(start_time) =1 then 'Sunday'
when dayofweek(start_time) =2 then 'Monday'
when dayofweek(start_time) =3 then 'Tuesday'
when dayofweek(start_time) =4 then 'Wednesday'
when dayofweek(start_time) =5 then 'Thursday'
when dayofweek(start_time) =6 then 'Friday'
when dayofweek(start_time) =7 then 'Saturday'
end
as day_of_week,
count(*) as listens_per_day
from listen_rcd
group by user_id,day_of_week
order by user_id,day_of_week
2025-05-14 渣男腰子可真行,端午中秋干不停 
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 asc