title: MySQL NFL QB rating - possible to set a minimum and maximum value if a sum adds up beyond a set range?
body: <p>I am trying to calculate the NFL's quarterback rating in MySQL. I have my four categories, but I need to be able to set a limit on each of them. If it adds up to a negative number, it needs to be 0. And if it adds up higher than 2.375 I need it to be 2.375.</p>
  <p>How can I add a minimum and maximum value to each of these four queries?</p>
  <pre><code>ROUND(((sum(case when pass_result='C' then 1 else 0 end)/sum(case when run_pass='P' then 1 else 0 end))-0.3)*5,3) AS 'Rule 1',
  ROUND(((sum(gain)/sum(case when run_pass='P' then 1 else 0 end))-3)*0.25,3) AS 'Rule 2',
  ROUND((sum(case when series_end='Touchdown' then 1 else 0 end)/sum(case when run_pass='P' then 1 else 0 end))*20,3) as 'Rule 3',
  ROUND((2.375-(sum(case when pass_result='IN' then 1 else 0 end)/sum(case when run_pass='P' then 1 else 0 end))*25),3) as 'Rule 4'
  </code></pre>