Hello,

The view VRAND below generates a series of 3 randomly chosen integers -

CREATE VIEW vrand as with r(num, rand) as (
select 1, cast(round(abs(random())/9223372036854775808) as int)
union all
select num+1, cast(round(abs(random())/9223372036854775808) as int) from r)
select num from r where rand=1 limit 3;

sqlite> select * from vrand;
num
1
2
4

sqlite> select count(*) from vrand;
count(*)
3

Now I would like to add a "running number" column with a result set like -

running_num, num
1, 1
2, 2
3, 4

However, the follow statement seems to trigger an infinite loop -

select (select count(*) from vrand where num <= v.num), num from vrand as v;

How can a running number column be added to this view?
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to