Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7724825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:47:09+00:00 2026-06-01T04:47:09+00:00

I have a TABLE elements with one COLUMN number, type SMALLINT that contains numbers

  • 0

I have a TABLE “elements” with one COLUMN “number”, type SMALLINT that contains numbers 1 thru 56. How can I generate unique sets of 5 numbers of every possible combination from 1 to 56, using an SQL statement?

In APL (programming language) a simple dyadic function 5!56 does the trick!

EDIT: In good ole MS-DOS QBASIC, I accomplished it like this:

10  OPEN "C:\5NUMBERS.OUT" FOR OUTPUT ACCESS READ WRITE AS #1
12  LET SER = 0

15  LET E = 56
30      FOR B5 = 5 TO E
40          FOR B4 = 4 TO E
50              FOR B3 = 3 TO E
60                  FOR B2 = 2 TO E
70                      FOR B1 = 1 TO E
80

88  IF B5 = B1 THEN 190
89  IF B5 = B2 THEN 190
90  IF B5 = B3 THEN 190
91  IF B5 = B4 THEN 190

92  IF B4 = B1 THEN 180
93  IF B4 = B2 THEN 180
94  IF B4 = B3 THEN 180

95  IF B3 = B1 THEN 170
96  IF B3 = B2 THEN 170

97  IF B2 = B1 THEN 160

98 LET SER = SER + 1

100 PRINT #1, SER; "|";
130 PRINT #1, B1; "|";
131 PRINT #1, B2; "|";
132 PRINT #1, B3; "|";
133 PRINT #1, B4; "|";
134 PRINT #1, B5; "|";
140 PRINT #1, B1 + B2 + B3 + B4 + B5; "|"

150                     NEXT B1
160                 NEXT B2
170             NEXT B3
180         NEXT B4
190     NEXT B5
205 CLOSE
210 END
220 SYSTEM 

This, by the way, created my load file into an INFORMIX-SQL table

TABLE combos
(
seq_id SERIAL,
ball_1 SMALLINT,
ball_2 SMALLINT,
ball_3 SMALLINT,
ball_4 SMALLINT,
ball_5 SMALLINT,
sum    SMALLINT
);

I used combos.sum to generate a bell curve graph, showing the count of combinations having the same sum of each element.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:47:10+00:00Added an answer on June 1, 2026 at 4:47 am

    If you want to include pairs of identical numbers, e.g. (5,5):

    SELECT e1.number AS number1
          ,e2.number AS number2
    FROM   elements e1
          ,elements e2
    WHERE  e1.number <= e2.number;
    

    If you want to only have different numbers in each pair:

    SELECT e1.number AS number1
          ,e2.number AS number2
    FROM   elements e1
          ,elements e2
    WHERE  e1.number < e2.number;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a a number of elements in one table column and I
I have a table that has a column that contains links. Each cell in
I have the following Table elements how do i run a query that reproduce
I have one column in my table which will store data in string format
I have the following xml that stores table definations. How can I loop through
I have a view that displays a table: rows represent days - one row
I have a table as follows; <table> <tr> <th scope=col></th> <th scope=col>Column One</th> <th
I have some irregular data in one column. my.table <-read.table(text=ticker,date,last a,12/20/2011,289295 a,12/21/2011,NA a,12/27/2011,297001 a,12/28/2011,NA
i have table unser it i have one td with elemets inside the menu
I have a table where each row has 13 TD elements. I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.