September 23, 2013

A complex mysql “over” query

mysql

A complex mysql “over” query

SELECT Candidates.CID, Candidates.NAME, Candidate_Scores.SCORE FROM
Candidates,
(SELECT CID, SCORE
FROM (
SELECT CID, SCORE, Rank() over (Partition BY CID ORDER BY SCORE DESC ) AS Rank
FROM Candidate_Scores
) rs WHERE Rank <= 3) Candidate_Scores WHERE Candidates.CID = Candidate_Scores.CID

Last updated: March 19, 2014
Did it helped? One thought on “A complex mysql “over” query
  1. Farhan

    Hi, Please also explain the functionality of OVER in Mysql. Explain the scenario where over use in MYSQL.

    thanks

Comments are closed.