random(): Returns a pseudo-random value from 0.0 to 1.0 : random « Math Functions « PostgreSQL






random(): Returns a pseudo-random value from 0.0 to 1.0


postgres=#
postgres=# --random(): Returns a pseudo-random value from 0.0 to 1.0
postgres=# SELECT random() AS natural_random,
postgres-#        round(random() * 9) + 1 AS one_through_ten,
postgres-#        trunc(random() * 99) + 1 AS one_through_one_hundred;
  natural_random   | one_through_ten | one_through_one_hundred
-------------------+-----------------+-------------------------
 0.946445006386584 |               6 |                      90
(1 row)

postgres=#
           
       








Related examples in the same category

1.Get random number