Sometimes you face the situation where you have some items ranked, and someone always tries to bump the ranking by voting a "perfect 100" to a particular item.And when you rank the items with average function or root mean square, that single "perfect 100" vote still bumps the item at top of ranking.Well, have you looked a Bayesian Estimate?-- Prepare sample dataDECLARE @Sample TABLE ( userID INT, vote INT )INSERT @SampleSELECT 3, 40 UNION ALLSELECT 3, 60 UNION ALLSELECT 0, 100 UNION ALLSELECT 1, 100 UNION ALLSELECT 1, 100 UNION ALLSELECT 1, 90 UNION ALLSELECT 1, 100 UNION ALLSELECT 1, 90 UNION ALLSELECT 1, 100 UNION ALLSELECT 1, 90 UNION ALLSELECT 2, 60 UNION ALLSELECT 2, 70 UNION ALLSELECT 2, 100 UNION ALLSELECT 2, 90 UNION ALLSELECT 2, 60 UNION ALLSELECT 2, 20-- Set minimum level of votes to be countedDECLARE @minVotes INTSET @minVotes = 30-- AverageSELECT userID, AVG(1.0E * vote) AS AverageFROM @SampleGROUP BY userID--HAVING COUNT(*) >= @minVotesORDER BY userID-- Root Mean SquareSELECT userID, SQRT(SUM(Items * thePow) / SUM(Items)) AS [Root Mean Square]FROM ( SELECT userID, POWER(vote, 2.0E) AS thePow, 1.0E * COUNT(*) AS Items FROM @Sample GROUP BY userID, vote ) AS dGROUP BY userID--HAVING SUM(Items) >= @minVotesORDER BY userID-- Bayesian EstimateSELECT s.userID, 1.0E * COUNT(*) / (1.0E * COUNT(*) + @minVotes) * AVG(s.vote) + (@minVotes / (1.0E * COUNT(*) + @minVotes)) * MIN(c.c) AS [Bayesian estimate]FROM @Sample AS sCROSS JOIN ( SELECT AVG(1.0E * vote) AS c FROM @Sample ) AS cGROUP BY s.userID--HAVING COUNT(*) >= @minVotesORDER BY s.userID
For more information about Bayesian Estimate, see http://www.imdb.com/chart/top
E 12°55'05.63"N 56°04'39.26"