[sqlite] Get X number of random integer numbers between A and B

2016-01-22 Thread Stephan Beal
On Fri, Jan 22, 2016 at 12:22 PM, Stephan Beal wrote: > > > On Fri, Jan 22, 2016 at 12:11 PM, Bart Smissaert > wrote: > >> Say I want 1 random numbers between 100 and 1000 how can I do that >> without >> selecting from a table? >> I know I can do: >> select abs(random() %(1000 - 100)) + 100

[sqlite] Get X number of random integer numbers between A and B

2016-01-22 Thread Bart Smissaert
Thanks, will look at that as well. I was thinking achieving this with a user function, maybe using sqlite3_randomness, but I this looks very good. RBS On Fri, Jan 22, 2016 at 12:39 PM, Stephan Beal wrote: > On Fri, Jan 22, 2016 at 12:22 PM, Stephan Beal > wrote: > > > > > > > On Fri, Jan 22,

[sqlite] Get X number of random integer numbers between A and B

2016-01-22 Thread Bart Smissaert
Thanks, that works very well and is a lot faster than involving a table. I don't need the x output, so I have done: with conf(max) as (select 1), rnd(n, x) as (select abs(random() %(1000 - 100)) + 100, 1 union all select abs(random() %(1000 - 100)) + 100, x + 1 from rnd where x < (select max

[sqlite] Get X number of random integer numbers between A and B

2016-01-22 Thread Stephan Beal
On Fri, Jan 22, 2016 at 12:11 PM, Bart Smissaert wrote: > Say I want 1 random numbers between 100 and 1000 how can I do that > without > selecting from a table? > I know I can do: > select abs(random() %(1000 - 100)) + 100 as rnd from TableWith1Rows > but there must be a better way. > >

[sqlite] Get X number of random integer numbers between A and B

2016-01-22 Thread Bart Smissaert
Say I want 1 random numbers between 100 and 1000 how can I do that without selecting from a table? I know I can do: select abs(random() %(1000 - 100)) + 100 as rnd from TableWith1Rows but there must be a better way. RBS