Skip to content

Instantly share code, notes, and snippets.

@kakha13
Last active December 28, 2015 23:19
Show Gist options
  • Save kakha13/7577820 to your computer and use it in GitHub Desktop.
Save kakha13/7577820 to your computer and use it in GitHub Desktop.
100% cool rating system query for SQL that will give you right result. Score and Timer calculation Rating
-- BY Kakha Giorgashvili (KAKHA13)
-- Rating system query
-- score = Users Score
-- timer = Interval from begining to end
-- 1.8 is gravity what helps query to get 100% right result
SELECT
*,
(`score` - 1) / POWER(`timer`, 1.8) AS rating
FROM
column_name
ORDER BY
rating DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment