|
I have the below input The output will be The Combined Match Played column is the sum of the values of Match Played column of those players. e.g. for Combined Played 1,2 the Combined Match Played value is 10 + 5 = 15. similarly, Combined Runs Made is the sum of the Runs MAde column of the individual players. e.g. for the same example, the Combined Runs MAde column is 200 +100 =300. Thanks
(comments are locked)
|
|
First of all, what you want is combinations not permutations. The trick here is to generate a recursive cte that gives you all the combinations, summing the matches and runs is a simple next step. The combination cte is controlled by only adding playerids that are greater than the one you started with ( Try this Is the ordering important? You want to watch out for the number of combinations here - 10 players is over 1000 combinations, 20 is well over 1M results.... If you want to test it (please, on a DEV server!) change the playerid to be an identity, comment out Kev's insert code and use
Jun 08 '11 at 02:57 AM
Fatherjack ♦♦
Yes I should have pointed out that this will bomb out at 100 recursions by default
Jun 08 '11 at 02:59 AM
Kev Riley ♦♦
!!! that would be 1,267,650,600,225,229,401,496,703,205,376 combinations. Better have a decent processor
Jun 08 '11 at 03:11 AM
Fatherjack ♦♦
That's one heck of a cricket team
Jun 08 '11 at 08:16 AM
Kev Riley ♦♦
not really, if this is for something like a fantasy cricket league then comparison of all players in games vs all players (i.e. over a season) then you might have 10-15 players per team and maybe 10 teams in a league/division. What you would have to do is keep out the combinations that didnt play - rather than allowing for all combinations. I think if thats the case then the schema needs to take into account a fixtures table and a teams table so that the joins would prevent over linking of players details.
Jun 08 '11 at 08:52 AM
Fatherjack ♦♦
(comments are locked)
|


What are you actually looking to achieve with this? What is the question you are actually asking?
@mrs_fatherjack - looks like it could be used for a fantasy cricket league may be?
Right.. something of that sort