0

For example, this doesn't work,

SELECT a.score, a.r as Rank FROM 
    (SELECT score, dense_rank() over (order by Score desc) as r
        FROM Scores) a
ORDER BY a.r;

That is because Rank is also a function. I tried to replace Rank with [Rank] but that still doesn't work. So, what is the solution?

0

1 Answer 1

1

You can give it a different name. That is what I would recommend. But absent that, the escape character in MySQL is the backtick:

SELECT a.score, a.r as `Rank`
FROM (SELECT score, dense_rank() over (order by Score desc) as r
      FROM Scores
     ) s
ORDER BY a.r;

Or the SQL standard, double quotes:

SELECT a.score, a.r as "Rank"
FROM (SELECT score, dense_rank() over (order by Score desc) as r
      FROM Scores
     ) s
ORDER BY a.r;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.