On Fri, Jan 22, 2016 at 12:11 PM, Bart Smissaert <bart.smissaert at gmail.com>
wrote:

> Say I want 10000 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 TableWith10000Rows
> but there must be a better way.
>
>
Maybe not perfect, but this seems to work...

sqlite> with conf(max) as (select 10), 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 from conf)) select * from rnd;
668|1
301|2
619|3
380|4
412|5
263|6
563|7
877|8
573|9
468|10

just swap out the 'conf' part with 1000.



-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
"Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
those who insist on a perfect world, freedom will have to do." -- Bigby Wolf

Reply via email to