MySQL Forums
Forum List  »  Newbie

Get 20 most frequent pairs(2/2) and triplets(3/3) of numbers mysql
Posted by: jhon travolta
Date: November 29, 2015 08:36AM

I'm trying to get the 20 most frequent pairs(2/2) and triplets(3/3) of numbers, my table looks like this:
+----+------+------+------+------+------+------+------+------+------+------+
| id | nr_1 | nr_2 | nr_3 | nr_4 | nr_5 | nr_6 | nr_7 | nr_8 | nr_9 | nr_10|
+----+------+------+------+------+------+------+------+------+------+------+
| 1 | 1 | 3 | 19 | 23 | 28 | 32 | 39 | 42 | 60 | 80 |
+----+------+------+------+------+------+------+------+------+------+------+
| 2 | 1 | 3 | 18 | 24 | 29 | 33 | 40 | 43 | 61 | 80 |
+----+------+------+------+------+------+------+------+------+------+------+
| 3 | 1 | 2 | 3 | 25 | 30 | 34 | 41 | 44 | 62 | 78 |
+----+------+------+------+------+------+------+------+------+------+------+

Imagine that there is a lottery with 10 drawn numbers out of 80 and in the table are the results.

I want a way to find the most drawn pairs and triplets from any numbers of draws.

Per example:

Pairs of numbers(two numbers that have been drawn toghether):

-the numbers 1 and 3 have been drawn together 3 times, which makes it the most drawn pair of numbers out of the 3 draws.

-the numbers 1 and 80 have been drawn together 2 times along with 3,80 which also has been drawn 2 times out of 3 draws.

As for most drawn triplets( any combination of 3 numbers):

-1,3,80 is the most common triplet, being drawn together 2 times out of the 3 draws.

Options: ReplyQuote


Subject
Written By
Posted
Get 20 most frequent pairs(2/2) and triplets(3/3) of numbers mysql
November 29, 2015 08:36AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.