为什么我不能对SQL“排名分数"使用density_rank? [英] Why can't I use dense_rank for SQL 'rank scores'?

查看:197
本文介绍了为什么我不能对SQL“排名分数"使用density_rank?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SQL中的density_rank函数来解决leetcode的排名得分"问题( https://leetcode.com/problems/rank-scores/description/):

I'm using the dense_rank function in SQL to solve the leetcode 'rank scores' problem(https://leetcode.com/problems/rank-scores/description/):

select Score, dense_rank() over (order by Score) Rank
from Scores
order by Score desc

它总是给我以下错误:

Line 2: SyntaxError: near '(order by Score) Rank
from Scores
order by Score desc'

我想知道如何使这个答案正确吗?非常感谢!

I wonder how to make this answer correct? Thanks a lot!

此外,我意识到大多数人在不使用DENSE_RANK函数的情况下使用答案,这非常令人困惑,因为对我来说DENSE_RANK可能是解决问题的最直观的方法.有人知道吗再次感谢!

Also, I realized most people use an answer without using the DENSE_RANK function, which is quite confusing since to me DENSE_RANK is probably the most intuitive way to solve the problem. Anyone have any idea? Thanks again!

推荐答案

修改后的答案

我的SQL不支持density_rank,但是它确实支持其他窗口函数. 查看寻求帮助.

My SQL does not support dense_rank, it does support other window functions though. Check out this answer for help.

或者,您可以在另一台SQL服务器中运行代码

Alternatively you could run the code in another SQL server

这篇关于为什么我不能对SQL“排名分数"使用density_rank?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆