题解 | 电竞赛事战队近期战绩查询

电竞赛事战队近期战绩查询

https://www.nowcoder.com/practice/7dda27e223a94184a3269ed99ac42fbe

题目要求用lateral join,找ai学习了一下,看起来比窗口函数排名要高级一些

select
e.team_name,
e.region,
m.match_date,
m.opponent,
m.kills,
m.deaths,
m.kda_ratio,
m.result
from esports_teams e
left join lateral (
    select mr.match_id,
           mr.match_date,
           mr.opponent,
           mr.kills, 
           mr.deaths,
           round(mr.kills/mr.deaths,2) kda_ratio,
           case when mr.is_win = 1 then '胜'
                when mr.is_win = 0 then '负'
            end result
    from match_records mr
    where e.team_id = mr.team_id
    order by mr.match_date desc
    limit 3
) m on true
order by e.team_id, m.match_date desc, m.match_id

全部评论

相关推荐

政委qqq:这道题在算法竞赛里唯一考的就是高精度,但是只能难住C++这类语言,Python直接a+b秒天秒地
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务