Random Record Selection

M

Molasses26

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)
 
V

Van T. Dinh

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top