Subject Random multirow select, and RAND() alternative?
Author rbd523
Hey guys,

First issue, it seems that FB 1.5.x doesn't have a RAND() function
(??). I've read around and seen things that mention IB 5 having one
(but it being broken). Basically I need one though...does anyone
have a good UDF that emulates the RAND functionality? (returns a
random number between two bounds)

Secondly, I was looking into ways on _efficiently_ doing a multi-row
select of NON-REPEATED "random" rows, for a given search criteria. I
would like to do it all within PSQL (stored procedure). I've
explored several options, like a stored procedure using a FOR
SELECT ... DO construct (but that is row-by-row it seems), using
cursors, etc. But these are mostly row-by-row random options, and
with those, making sure a given randomly selected row isn't selected
twice seems difficult.

At this point I think the simplest way would be to do something like
the following:

SELECT DISTINCT * FROM footable WHERE ..... ORDER BY RAND()

that ORDER BY RAND()/NEWID() construct works in other DBs (like MS
SQL server, etc), but I don't know if it works in FB yet.

Any ideas or guidance in this area would be welcome!

Robby