× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



What does "select rand() from cumor order by 1" give you?

Regards, 
 
Guy 

------------------------------

date: Thu, 16 Feb 2006 14:58:57 -0500
from: Dan <dan27649@xxxxxxxxx>
subject: Re: Select a random record in SQL

On 2/16/06, John Joiner <john@xxxxxxxxxxxxxx> wrote:
>
> I'm not sure about the duplicates. I've experienced that as well, but
I
> typically use something like 'INT(RAND() * 1000' or something like
that so
> I
> don't get that floating point number.


Just doing a "select rand() from cumor" gives distinctively unique
floating
point values.

If I leave out the Order By rand() clause from the original statement
(where
rand() was in both the select and order by clauses), again, I get
distinctively unique floating point values.

But a "select rand() from cumor
            order by RAND()"  gives the duplicates.  Interesting.

You may or may not be aware that each time you invoke the RAND()
function,
> you should be getting a different random number. So, if you specify
RAND()
> in the field list and RAND() in the order by, the random number
returned
> in
> the field list will not necessarily be the same as the random number
used
> to
> order the records. At least this has been my experience.


That makes sense.

- Dan



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.