pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Luis Roberto Weck <luisroberto@siscobra.com.br>
To: pgsql-performance@lists.postgresql.org
Subject: Random function
Date: Tue, 24 Mar 2020 15:10:16 -0300
Message-ID: <95311e45-95e3-970b-e54f-3a4595d55dbb@siscobra.com.br> (raw)

Hi,

I am trying to generate some random data using the random() function.

However, I am getting the same result over mulitiple rows. This is a 
sample of the SQL I am using:

select (select string_agg(random()::text,';')
           from pg_catalog.generate_series(1,3,1) )
   from generate_series(1,10,1)

And I am getting something like:

|string_agg |
+--------------------------------------------------------------+
|0.243969671428203583;0.692578794434666634;0.291524752043187618|
|0.243969671428203583;0.692578794434666634;0.291524752043187618|
|0.243969671428203583;0.692578794434666634;0.291524752043187618|
|0.243969671428203583;0.692578794434666634;0.291524752043187618|
|0.243969671428203583;0.692578794434666634;0.291524752043187618|
|0.243969671428203583;0.692578794434666634;0.291524752043187618|
|0.243969671428203583;0.692578794434666634;0.291524752043187618|
|0.243969671428203583;0.692578794434666634;0.291524752043187618|
|0.243969671428203583;0.692578794434666634;0.291524752043187618|
|0.243969671428203583;0.692578794434666634;0.291524752043187618|

If this is the expected output, is there a way to always generate random 
numbers?






view thread (3+ messages)  latest in thread

Message-ID: <95311e45-95e3-970b-e54f-3a4595d55dbb@siscobra.com.br>
Permalink:  ../95311e45-95e3-970b-e54f-3a4595d55dbb@siscobra.com.br/
Also on:    postgresql.org/message-id/95311e45-95e3-970b-e54f-3a4595d55dbb@siscobra.com.br

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: luisroberto@siscobra.com.br, pgsql-performance@lists.postgresql.org
  Subject: Re: Random function
  In-Reply-To: <95311e45-95e3-970b-e54f-3a4595d55dbb@siscobra.com.br>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox