gdaem
gdaem

Reputation: 23

How can I create a series of numbers increasing by a decimal in BigQuery?

I'm trying to create a series of numbers for multiple samples using a distribution plot. I want to have numbers .01, .02, .03... etc. in a column by itself, just creating a random number.

I have tried randbetween(0,1) but I cannot have it run a specified number of times and it is also not in sequence. I also tried rand() but that didn't work either.

The output should be something like this:

  1. 0.000001
  2. 0.000002
  3. 0.000003
  4. 0.000004 ..... etc

Upvotes: 0

Views: 1211

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269823

Use generate_array() to generate a series of numbers. Then divide:

select cast(n / 1000000 as numeric)
from unnest(generate_array(1, 10)) n

Upvotes: 2

Related Questions