#### Topic: Grouping of combinations

Good afternoon, All!

I saw a search engine of bookmaker forks.

Faced such interesting task which it is possible means SQL and not to solve.

There is a table of coefficients from various bookmaker offices.

Looks approximately so:

Market type (for example - 12 - i.e. a possible outcome of a match - only a victory of one of players (for example - tennis). Or 1X2 - the drawn game here is still possible. For example - football)

Coefficient type (on a victory, or a drawn game)

ID the contender

ID event (match)

Let's assume that in this table coefficients on the same football match of 3 offices are written down:

Office | the Contender | coefficient Type | market Type | Coefficient

1 1 | the Contender 1 | the Victory | 1X2 | 1,5

2 1 | the Contender 1 | the Drawn game | 1X2 | 3

3 1 | the Contender 2 | the Victory | 1X2 | 5

4 1 | the Contender 2 | the Drawn game | 1X2 | 3

5 2 | the Contender 1 | the Victory | 1X2 | 1,6

6 2 | the Contender 1 | the Drawn game | 1X2 | 2,9

7 2 | the Contender 2 | the Victory | 1X2 | 7

8 2 | the Contender 2 | the Drawn game | 1X2 |2,9

9 2 | the Contender 1 | the Victory | 1X2 | 1,7

10 2 | the Contender 1 | the Drawn game | 1X2 | 2,8

11 2 | the Contender 2 | the Victory | 1X2 |7,1

12 2 | the Contender 2 | the Drawn game | 1X2 |2,8

(The drawn game for each office is stored 2 times - once for one contender, the second time for another)

And here a question: whether it is possible as that means SQL to show all possible "" combinations?

I.e. as a result of SQL request I would like to see here such table:

1 Combination 1 | 1 | the Contender 1 | the Victory | 1,5

2 Combination 1 | 1 | the Contender 1 | the Drawn game | 3

3 Combination 1 | 2 | the Contender 2 | the Victory | 7

4 Combination 2 | 2 | the Contender 1 | the Victory | 1,6

5 Combination 2 | 2 | the Contender 1 | the Drawn game | 2,9

6 Combination 2 | 1 | the Contender 2 | the Victory | 5

7 Combination 3 | 1 | the Contender 1 | the Victory | 1,5

8 Combination 3 | 2 | the Contender 1 | the Drawn game | 2,9

9 Combination 3 | 1 | the Contender 2 | the Victory | 5

I.e. "Combination" is a combination of coefficients of various offices on all possible outcomes of a match.

I could group such result across the field "combination", and apply various grouped functions to coefficients.

At me all boots in the program, all combinations there are made and all operation by means of arrays becomes. I want to simplify a program construction - all can be made SQL - request?