459,307 Members | 1,583 Online
Need help? Post your question and get tips & solutions from a community of 459,307 IT Pros & Developers. It's quick & easy.

# SELECT MAX(field) FROM table BUT MAKE SURE IT IS NOT LESS THAN 2000

 P: n/a How can I select the maximum value from a field, but make sure that the value i want stays greater than a cetrain value? I currently have this: SELECT A.rating, B.rating, 1/(1+10^((A.rating-B.rating)/400)) AS Expected, Round( -20*( [A].[rating]+[b].[rating] ) / ( SELECT MAX(rating) FROM teams ) + 50) AS K FROM teams AS A, teams AS B WHERE (A.teamid<>B.teamid) ORDER BY A.rating DESC , B.rating DESC; This works perfectly, except that the "SELECT MAX(rating) FROM teams" sub query is currently returning 1000, and that value should never be les than 2000. Im not trying to say that at least one team should be ranked above 2000, but rather that in order to calculate rankings, I need a value of at least 2000 for my maximum. This is based on the ELO system, in case you are wondering. Hopefully, John "otac0n" Gietzen Jan 17 '06 #1