当前位置:网站首页>字节数仓实习生面试sql题
字节数仓实习生面试sql题
2022-04-23 06:15:00 【山顶看数据】
题目要求
id cnt url
1 12 a
2 21 f
1 32 e相关说明:
cnt相当于日期
这里需要把这个表拆分成如下的类型
id 最大日期 url 最小日期 url
1 32 e 12 a
当时脑子突然一热,在面试官面前有点紧张,这道题也就没有做出来,面试完之后自己又重新审视了一下这道题,具体的sql语句如下
select
t3.id,t3.cnt,t3.url,t4.cnt,t4.url
from
(select
t1.*
from
(select
id,cnt,url,row_number() over(partition by id order by cnt) temp
from info) t1
where t1.temp <2 ) t3
join
(select
t2.*
from
(select
id,cnt,url,row_number() over(partition by id order by cnt desc) temp
from info) t2
where t2.temp <2) t4
on t3.id = t4.id
这道题主要的是要把多余的列剔除掉,表中只保留最大列和最小列。
版权声明
本文为[山顶看数据]所创,转载请带上原文链接,感谢
https://blog.csdn.net/li1579026891/article/details/121769754
边栏推荐
猜你喜欢
随机推荐
Systrace parsing
字节跳动2020秋招编程题:根据工号快速找到自己的排名
Raspberry Pie: two color LED lamp experiment
Chapter 2 pytoch foundation 2
GIS实战应用案例100篇(五十三)-制作三维影像图用以作为城市空间格局分析的底图
“Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
“泉”力以赴·同“州”共济|北峰人一直在行动
Chapter 5 fundamentals of machine learning
带低压报警的51单片机太阳能充电宝设计与制作(完整代码资料)
Gephi tutorial [1] installation
PyTorch 19. PyTorch中相似操作的区别与联系
AUTOSAR从入门到精通100讲(八十六)-UDS服务基础篇之2F
机器视觉系列(02)---TensorFlow2.3 + win10 + GPU安装
商业广场无线对讲系统解决方案
使用proteus仿真STM32超声波SRF04测距!Code+Proteus
Device Tree 详解
LPDDR4笔记
GIS实战应用案例100篇(五十二)-ArcGIS中用栅格裁剪栅格,如何保持行列数量一致并且对齐?
直观理解 torch.nn.Unfold
Modifying a column with the 'identity' pattern is not supported









