title: SQL Join on Table A value within Table B range
body: <p>I have two tables that can be seen in accompanying image.</p>
  
  <p><em>Table A</em> contains <strong>Department</strong>, <strong>Month</strong> and <strong>Average</strong>.</p>
  
  <p><em>Table B</em> contains <strong>Month</strong>, <strong>Year</strong>, <strong>RangeStart</strong>, <strong>RangeEnd</strong> and <strong>Colour</strong>.</p>
  
  <p>If you look at the screen shot of <em>Table B</em>, you will see for each Month you have a Green, Yellow, Orange and Red value. You also have a range.</p>
  
  <p><strong>What I need.........</strong></p>
  
  <p>I need a new column on <em>Table A</em> named 'Colour'. In this column, I need either Green, Yellow, Orange or Red. The deciding factor on which colour is assigned to the month will be the 'Average' column.</p>
  
  <p>For example:</p>
  
  <p>DepartmentA for May's Average is equal to <code>0.96</code>
  Upon referencing <em>Table B</em>, I can see that line 8, <code>0.75+</code> will be the range this fits into. Therefore Red is the colour I want placed in <em>table A</em> next to Mays average.</p>
  
  <p>I have left RangeEnd for the highest range per month as NULL as it is basically <code>75+</code>, anything greater than <code>0.75</code> slots in here.</p>
  
  <p>Can anyone point me in the right direction that is not too time consuming.</p>
  
  <p><img src="https://i.stack.imgur.com/g6zLd.png" alt="enter image description here"></p>