Subject Re: [firebird-support] Re: Random Records
Author Ivan Prenosil
> I have tried the obvious solution, and of course it does not work :-)
> I declared the Rand UDF and tried
> select
> A.A, Rand()
> from
> A
> order by
> 2
> The order of the records are always the same since Rand Returns the same
> value for all records, the result tend to be identical to a select
> without an order by.
> But, What about if you try to write an UDF that returns random numbers
> not based on system time (as rand do) and use the previous number as a
> seed for the next one ?

The Rand() function is fixed in FB2, I think you can use it in FB1.5 too.
But the above statement will always read whole table !

Lester, do you need "single select statement" solution ?
Can you afford to create generator that would remember last used ID
on each request ? Or just simply do something like
select first 1 * from ... where id > gen(last_id, 7) order by id
and reset generator if no record is returned ...