Why this query does not word


  • 0
    S

    I do not know why the second query works while the first does not

    The following query does not work

    SELECT
    Score, (SELECT COUNT(*) FROM (SELECT DISTINCT Score FROM Scores) tmp  WHERE tmp.Score >= Score) AS Rank
    FROM Scores ORDER BY Score DESC
    

    However, this query works

    SELECT
    Score, (SELECT COUNT(*) FROM (SELECT DISTINCT Score s FROM Scores) tmp WHERE s >= Score) AS Rank
    FROM Scores ORDER BY Score DESC
    

  • 0
    A

    Also wondering why the first one does not work.
    When testing the case [0.01][0.00][0.00], it output [0.01, 2],[0.00, 2].[0.00, 2].
    It seems like, when judge >=, it worked as 0.00 >= 0.01.
    I guess it is something about datatype issue.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.