Random Record Selection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!
I seem to be having a brain doner Monday and I can't figure out how to make
the query from Joe Foster work!
I entered the first part of the code into a module but then I'm not sure
what to do with the last part. I tried entering it as an SQL query using my
table name dbo_bs_excp but I don't know what the ".question" in the Order By
is supposed to be.
Please help!!

select top 10 dbo_bs_excp.* from dbo_bs_excp
where dbo_bs_excp.resolved_dt > #11/1/2006# AND randomizer() = 0
order by rnd(isnull(dbo_bs_excp.question) * 0 + 1)
 
IIRC, you can replace it with any Field in your Table. If you look at it,
the expression inside rnd() always evaluated to 1!.

The reason to use a Field name is to trick JET to go to VBA to re-evaluated
the rnd() function for each row (otherwise, JET will optimize and will call
the function rnd() only once and use the same value for each row).
 
Back
Top