Still trying to figure out what he really wants, but I am thinking maybe this is a linear programming problem? Let us be honest, SQL is not really good at fancy math. We designed the language. Our intent was that it would put together data and throw that data over to another tier. It was equipped for specialized uses like linear programming programming, statistics, fancy display graphics, voice over the Internet, and whatever other wonderful things people decide to do with data when they get it:-)
Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL