全站第 38/1262 名
解决了 43/335 题
中等: 2/76
入门: 24/77
困难: 0/29
简单: 14/114
草履虫: 3/39
过去1年一共提交 85 次
Sep
Oct
Nov
Dec
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
勋章 ①金银铜:在竞赛中获得第一二三名;②好习惯:自然月10天提交;③里程碑:解决1/2/5/10/20/50/100/200题;④每周打卡挑战:完成每周5题,每年1月1日清零。







收藏
收藏日期 | 题目名称 | 解决状态 |
---|---|---|
2025-08-08 | 各行业第一家上市公司 | 已解决 |
2025-08-05 | 小结(2)越花越多是死罪,按月统计Substr | 未解决 |
2025-08-05 | 小结(1)大数据早就能扫黄,找足证据不慌张 | 已解决 |
2025-08-04 | 表连接(2)渣男去过我对象没去过,那就用LeftJoin | 已解决 |
2025-02-27 | 字符串与通配符(2)好多关键词做规则,可以使用rlike | 已解决 |
2025-02-24 | 分组与聚合函数(5)五花八门的项目,其实都有固定套路(2) | 已解决 |
评论笔记
评论日期 | 题目名称 | 评论内容 | 站长评论 |
---|---|---|---|
2025-08-08 | 每个行业超过20年的公司 | ||
2025-08-08 | 各行业第一家上市公司 | ||
2025-08-07 | 每年在深交所上市的银行有多少家 | ||
2025-08-05 | 时间日期(5)三腿爱往会所走,全当良心喂了狗 |
提交记录
提交日期 | 题目名称 | 提交代码 |
---|---|---|
2025-08-08 | 周杰伦的最受欢迎的专辑 |
select album_info.album_id,album_info.album_name,count(1) as listener_count from album_info left join song_info on album_info.album_id = song_info.album_id left join listen_rcd on listen_rcd.song_id = song_info.song_id left join singer_info on singer_info.singer_id = song_info.origin_singer_id where singer_info.singer_name='周杰伦' and listen_rcd.if_finished = 1 group by album_info.album_id,album_info.album_name order by listener_count limit 1 |
2025-08-08 | 拼接歌曲名和专辑名 |
select song_name , CONCAT(song_name, '-', album_name) as song_album from song_info left join album_info on song_info.album_id = album_info.album_id |
2025-08-08 | 用户听歌习惯的时间分布 |
select user_id,DAYNAME(start_time) as day_of_week,count(1) from listen_rcd group by user_id,DAYNAME(start_time) order by user_id,DAYNAME(start_time) asc |
2025-08-08 | 特定歌曲的播放记录 |
select listen_rcd.id,listen_rcd.user_id,listen_rcd.start_time,listen_rcd.song_id,listen_rcd.if_finished from singer_info left join song_info on singer_info.singer_id = song_info.origin_singer_id left join listen_rcd on listen_rcd.song_id = song_info.song_id where song_info.song_id=13 and listen_rcd.if_finished = 1 and date(listen_rcd.start_time) between '2023-12-10'and '2023-12-31' order by start_time |
2025-08-08 | 特定歌曲的播放记录 |
select listen_rcd.id,listen_rcd.user_id,listen_rcd.start_time,listen_rcd.song_id,listen_rcd.user_id from singer_info left join song_info on singer_info.singer_id = song_info.origin_singer_id left join listen_rcd on listen_rcd.song_id = song_info.song_id where song_info.song_id=13 and listen_rcd.if_finished = 1 and date(listen_rcd.start_time) between '2023-12-10'and '2023-12-31' order by start_time |
2025-08-08 | 特定歌曲的播放记录 |
select listen_rcd.id,listen_rcd.user_id,listen_rcd.start_time,listen_rcd.song_id,listen_rcd.user_id from singer_info left join song_info on singer_info.singer_id = song_info.origin_singer_id left join listen_rcd on listen_rcd.song_id = song_info.song_id where song_info.song_id=13 and listen_rcd.if_finished = 1 and date(listen_rcd.start_time) between '2023-12-10'and '2023-12-31' |
2025-08-08 | 2020年后上市的医药公司 |
select year(list_date) as Y, sum(case when name rlike '医|药|生物' then1 else 0 end ) as cnt from stock_info where year(list_date) between 2020 and 2024 group by Y order by Y |
2025-08-08 | 2020年后上市的医药公司 |
select * from stock_info where year(list_date) between 2020 and 2024 and name rlike '医|药|生物' |
2025-08-08 | 输出特定日期上市的银行 |
select * from stock_info where date(list_date) >='2006-06-01' and date(list_date) <='2006-09-01' and name like '%银行%' |
2025-08-08 | 21世纪上市的银行 |
select * from stock_info where industry='银行' andyear(list_date)>=2000 order by list_date |
2025-08-08 | 21世纪上市的银行 |
select * from stock_info where area = '北京' and industry='银行' andyear(list_date)>=2000 order by list_date |
2025-08-08 | 输出地区为北京的所有银行 |
select * from stock_info wherearea='北京' and name like '%银行%' order by list_date |
2025-08-08 | 统计特定行业内的公司名长度分布 |
select industry,AVG(length(name)) AS avg_name_length, MAX(length(name)) AS max_name_length, MIN(length(name)) AS min_name_length from stock_info WHERE industry IN('通信设备','生物制药','旅游景点','医疗保健','食品') group by industry |
2025-08-08 | 每个行业超过20年的公司 |
with industry_avg_total as ( select industry, sum(DATEDIFF(CURRENT_DATE(), list_date))/count(1) as avg_age_days, sum(DATEDIFF(CURRENT_DATE(), list_date)) as age_days, count(1) as total_companies from stock_info group by industry ) , industry_over_20 as ( select industry, count(1) as total_companies from stock_info where DATEDIFF(CURRENT_DATE(), list_date) >=(365*20) group by industry ) select industry_avg_total.industry, industry_avg_total.avg_age_days, industry_over_20.total_companies as over_20_years, industry_avg_total.total_companies, industry_over_20.total_companies/industry_avg_total.total_companies as proportion_over_20_years from industry_avg_total left join industry_over_20 on industry_avg_total.industry = industry_over_20.industry order by avg_age_days desc |
2025-08-08 | 各地区包含“中国”或“中”字开头的公司数量及比例 |
select area, count(1) as total_companies, sum(case when name rlike '中国|^中' then 1 else 0 end) as chinese_named_companies, ROUND(SUM(CASE WHEN name rlike '中国|^中' THEN 1 ELSE 0 END) / COUNT(*),3) AS proportion from stock_info group by area order by proportion desc limit 5 |
2025-08-08 | 各地区包含“中国”或“中”字开头的公司数量及比例 |
select area, count(1) as total_companies, sum(case when area rlike '中国|^中' then 1 else 0 end) as chinese_named_companies, ROUND(SUM(CASE WHEN name rlike '中国|^中' THEN 1 ELSE 0 END) / COUNT(*),3) AS proportion from stock_info group by area order by proportion desc limit 5 |
2025-08-08 | 每个行业最早上市的公司 |
selectts_code, symbol, name, area, industry, list_date from ( select stock_info.* , row_number()over(partition by industry ORDER BY list_date ASC ) as Sort from stock_info where name rlike '^中国|中' )as table1 where Sort = 1 |
2025-08-08 | 中字头上市企业 |
select count(*) from stock_info where industry in('通信设备','生物制药','旅游景点 ','医疗保健','食品') and name rlike'华|中' |
2025-08-08 | 各行业第一家上市公司 |
with min_listdateas ( select industry, min(list_date) as min_list_date from stock_info group by industry ) select stock_info.* from stock_info inner join min_listdate onstock_info.industry = min_listdate.industry and stock_info.list_date = min_listdate.min_list_date order by stock_info.list_date asc |
2025-08-08 | 各行业第一家上市公司 |
with min_listdateas ( select industry, min(list_date) as min_list_date from stock_info group by industry ) select stock_info.* from stock_info rightjoin min_listdate onstock_info.industry = min_listdate.industry and stock_info.list_date = min_listdate.min_list_date order by stock_info.list_date asc |