Skip to content

Instantly share code, notes, and snippets.

@ChiChou
Last active July 4, 2016 10:39
Show Gist options
  • Save ChiChou/8862382 to your computer and use it in GitHub Desktop.
Save ChiChou/8862382 to your computer and use it in GitHub Desktop.
Hacker News 排名算法的MYSQL函数实现
-- (p - 1) / (t + 2)^1.5
CREATE FUNCTION SP_POINTS(P SMALLINT(5), CREATED TIMESTAMP)
RETURNS TINYINT(3)
RETURN (P - 1) / POW(TIMESTAMPDIFF(HOUR, CREATED, NOW()) + 2, 1.5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment