Dennis Cote wrote:
Nick,
Each call to the random() function in your statement generates a new
random number. To reuse the same random number multiple times you need
to save it somewhere. The SQL statement below should do what you want.
It save the random number in a temp table which is joined to your
table (effectively the same random number is appended to each row in
your table).
select *, rand.number
from MyTable
join (select random(*) as number) as rand
where start_col >= rand.number
and end_col < rand.number;
Nick,
I just thought I should clarify my SQL. The select clause should be
select * from MyTbale join...
since the random number is already included in each row of the joined
table.
Dennis Cote