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



Nice and simple idea! Thank you, Shalom.

"Shalom Carmel" <shalom@xxxxxxxxxx> wrote in message news:<mailman.2669.1203000041.1203.midrange-l@xxxxxxxxxxxx>...
the rand sql function can be used to shuffle numbers.
Suppose that you want to randomly shuffle the numbers from 1..100 .

First, create a table with an automatic identity row. In our example, the
identity row saves us the effort of creating the population to be shuffled.
A sequence can be used instead, or you can fill it up programatically.

CREATE TABLE shuffle (nid SMALLINT NOT NULL GENERATED ALWAYS AS IDENTITY
(START WITH 1 INCREMENT BY 1 CYCLE),
rnd DECIMAL (10 , 10) )

Now, execute the following 100 times
INSERT INTO shuffle (rnd) VALUES(RAND())

We have created a table with a hundred rows numbered 1 to 100, and each row
contains a random number.

The following SQL will display the shuffled sequence.

SELECT nid FROM shuffle ORDER BY rnd


Shalom Carmel
-----------------------
www.venera.com

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.