Thanks bricklen. I found another way in PostgreSQL 9.1.0 Documentation.
SELECT * INTO random_number FROM random(); -- random function gives me a random value among 0.0 -- and 1.0 SELECT * INTO rounded_number FROM round(random_number * 5); -- this line is completly obviously. Saludos, Karel Riverón Consejo Científico Estudiantil Universidad de las Ciencias Informáticas ----- Original Message ----- | From: "bricklen" <brick...@gmail.com> | To: "Karel Riveron Escobar" <kesco...@estudiantes.uci.cu> | Cc: pgsql-general@postgresql.org | Sent: Saturday, May 25, 2013 11:50:03 AM | Subject: Re: [GENERAL] Random numbers | On Sat, May 25, 2013 at 8:45 AM, Karel Riveron Escobar < | kesco...@estudiantes.uci.cu > wrote: | | I want to generate random numbers in Pl/pgSQL. How can I do this? | | | To be more specific, I have to generate random numbers among 0 and | | 5. | | One way: | select n from unnest(ARRAY[0,1,2,3,4,5]) n order by random() limit 1; http://www.uci.cu