Random Range
From PostgreSQL wiki
Jump to navigationJump to searchby Scott Bailey 'Artacus'
CREATE OR REPLACE FUNCTION random(numeric, numeric)
RETURNS numeric AS
$$
SELECT ($1 + ($2 - $1) * random())::numeric;
$$ LANGUAGE 'sql' VOLATILE;
Usage
SELECT random(1,10)::int, random(1,10);
random random
--------- ----------------
5 3.20581795740873