I am looking to automate a process that I am using to pick dog sled teams for the Iditarod. A group of about 50 of us every year have a competition sort of like fantasy football or other sports where you pick 8 dog sled teams and you get points awarded to you based on how they place overall. Based on their current ranking, the teams cost x amount of dollars to have on your list of 8. You must remain under $100,000 total. What I started to do a few years ago is I take raw data from the Iditarod websites and I pull it into sql server and then I do some trend analysis and such. I then have a query to pull all of the current year racers and sort them by their trend calculation. I then pick out my 8 teams manually while having to ensure I stay under the 100k cap. What I am looking to do is automate that picking process so that the query will return me the top 8 teams while staying under the cap. What I don't want is for the query to give me the top 2 racers that are 90k total and then give me the bottom 6 racers that are 1500 a piece or whatever.

Here is the actual data, only 49 rows total. So, you can see their is a cost, a rank, and a trend calculation. I am thinking there has to be a way to write a query that would basically look at the sum of the trend across a group of 8 racers where the total cost is under 100k. It would likely have to do this calculation numerous times across the dataset so that it could determine which grouping of 8 has the highest trend calculation sum while maintaining the cost limit. This is obviously a trivial question and not a work related problem, but thought it would be fun to get some much bigger brains then mine working on a potential solution so I can automate my "mush madness" process :)

RACER_NAMECOSTRankTREND_POWER_CALCJeff Deeter16000180.075133Travis Beals25000120.062658Jessie Holmes23000130.058489Michelle Phillips21000150.050182Mille Porsild2800090.049422Ramey Smyth27000100.041991Paige Drobny22000140.036373Aaron Burmeister3200060.028302Joar Leifseth Ulsom4000030.023893Matthew Failor10000220.01628Mitch Seavey4500020.0147Brent Sass3300050.014591Richie Diehl26000110.014267Peter Kaiser3500040.012196Ryan Redington2900080.00925Anna Berington5000240.008707Kristy Berington5000250.008443Lev Shvarts5000230.008416Matt Hall20000160.005387Nicolas Petit3100070.004903Mats Pettersson14000190.0038Aaron Peck11000210.003342Ryne Olson5000260.001251Dallas Seavey5100010.000792Dan Kaduce19000170.000444Deke Naaktgeboren3000280Eric Kelly1000350Gerhardt Thiart1000460Hanna Lyrek1000420Lisbet Norris1000340Martin Buser3000300Martin Massicotte1000410Matt Paveglio1000440Amanda Otto1000390Anja Radano1000330Apayauq Reitan1000490Bridgett Watkins1000380Chad Stoddard3000310Joe Taylor1000400Joshua McNeal3000290Julie Ahnen1000370Kailyn Davis1000450Karin Hendrickson1000320KattiJo Deeter1000360Sean Williams1000430Sebastien Dos Santos Borges1000480Riley Dyche3000270Yuka Honda1000470Hugh Neff1200020-0.003167