Generating Random numbers in SQL

110 pts.
Tags:
SQL
SQL Anywhere
I HAVE a problem How can i use command or functios to combine numbers For example If k = 6 and n = 3 The command should return (as B1,B2,B3) 1,2,3 1,2,4 1,3,4 1,3,5 1,3,6 1,4,5 1,4,6 1,5,6 2,3,4 2,3,5 2,3,6 2,4,5 2,4,6 2,5,6 3,4,5 3,4,6 3,5,6 4,5,6 For all n of k numbers Thanks

Answer Wiki

Thanks. We'll let you know when a new response is added.

Sorry Ajibola, I must be having a low caffeine day. I can’t figure out what you are trying to do (i.e. what the relationship is between K and n and the B1, B2, B3 list.

Can you expand on this please?

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Stevewaltz
    I believe you are trying to choose all the distinct ways n numbers can be chosen from the first k positive integers without regard to order. By "without regard to order" I mean, for instance, that (1,2,3); (1,3,2); (2,1,3); (2,3,1); (3,1,2); and (3,2,1) are considered the same set of the 3 digits 1, 2 and 3. One way to do it is to create a single column table of integers (Oracle has had a way to do this without actually creating a table for a while now). The SQL below will work for the specific example. With this technique, k can be varied easily or provided as a variable, but the SQL has to be modified to deal with different values of n. (Just curious; why is the subject "Generating Random numbers in SQL"?) select a.integer_value b1, b.integer_value b2, c.integer_value b3 from integer_table a, integer_table b, integer_table c where a.integer_value
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following