SQLTeam.com | Weblogs | Forums

Fantasy Sports Draft Logic


Some friends of mine are fantasy sports junkies and have been interested in creating an algorithm that can sort through some criteria and suggest picks.

Essentially, you have the following problem:

You must select 9 players (1 QB, 2 WR, 2 RB, 1 Kicker, 1 Tight End, 1 Defense, 1 Flex Position of WR/RB)
You must spend less than 100 "dollars" on all players combined.
Obviously you want the most points possible.

So I have the following criteria to select against:
Expected Points

If I give a list of 1,000 players, I would like my SQL query to return a result with the 9 positions filled, for less than the allowed budget and with the maximum number of points.

Does anyone have any clue how to do this? It is easy enough to eyeball a hundred players and do something, but much harder, obviously, if there are a thousand players and every time another player picks that suggestion list could change.

Looking forward to hearing thoughts!


google Knapsack algorithm


This is great! Thank you much!