工作,我從MySQL查詢:Biased random in SQL?但遺憾的是沒有與PostgreSQL的工作:Modyfing MySQL查詢與PostgreSQL的
DECLARE @sample TABLE (id int, boost int)
INSERT @sample VALUES (1, 1), (2, 2), (3, 7)
SELECT
RAND(CHECKSUM(NEWID())) * boost AS weighted,
SUM(boost) OVER() AS boostcount,
id
FROM
@sample
GROUP BY
id, boost
ORDER BY
weighted DESC
它說,NEWID()函數不存在。任何人都可以幫我做這個查詢嗎?
非常感謝!
NEWID()不是一個MySQL的函數或者。 – 2012-04-26 12:40:22