By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,159 Members | 1,941 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,159 IT Pros & Developers. It's quick & easy.

getting "n" records using RND()

P: n/a
I need to get 20 random records from a table based on a condition.
The condition isn't a problem. I have tried select top 20 *,
rnd(field) from table, but that gets me the top 20 records. I need 20
random records. I would prefer to use SQL only for this if it is
possible.

Thanks in advance.
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Leslie" <ha*****@hotmail.com> wrote in message
news:59**************************@posting.google.c om...
I need to get 20 random records from a table based on a condition.
The condition isn't a problem. I have tried select top 20 *,
rnd(field) from table, but that gets me the top 20 records. I need 20
random records. I would prefer to use SQL only for this if it is
possible.

how about

select top 20 field
from leslie
order by rnd
(
field * 1000.0 * datepart ("s", now ( ))
)
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.