title: MySQL: Count entry once every month until entry change
body: <p>I need to make a list of how the score of each customer have chagned during time.  </p>
  
  <p>My problem is that I do not have a score for each month I want to look at. Hence I need to count the previous entry as the score for this month.  </p>
  
  <p>On top of that, if there is registered two scores in the same month, only the newest score should count in that month</p>
  
  <p>My table with data looks something like this: </p>
  
  <pre><code>| id | customer_id | score | created_at |   
  | 1  |     1       |  4    | 2016-05-01 |   
  | 2  |     2       |  4    | 2016-05-01 |  
  | 3  |     3       |  4    | 2016-05-01 |   
  | 4  |     1       |  3    | 2016-05-15 |  
  | 5  |     2       |  2    | 2016-06-01 |   
  | 6  |     3       |  2    | 2016-06-13 |   
  | 7  |     2       |  4    | 2016-07-01 |  
  | 8  |     2       |  2    | 2016-08-21 |  
  | 9  |     1       |  2    | 2016-08-01 |  
  | 10 |     1       |  1    | 2016-08-31 |  
  </code></pre>
  
  <p>I would like a result like this:   </p>
  
  <pre><code>|customer_id |   MONTH     | Score |
  |     1      |   2016-05   |   3   |
  |     2      |   2016-05   |   4   |
  |     3      |   2016-05   |   4   |
  |     1      |   2016-06   |   3   |
  |     2      |   2016-06   |   2   |
  |     3      |   2016-06   |   2   |
  |     1      |   2016-07   |   3   |
  |     2      |   2016-07   |   4   |
  |     3      |   2016-07   |   2   |
  |     1      |   2016-08   |   1   |
  |     2      |   2016-08   |   2   |
  |     3      |   2016-08   |   2   |
  |     1      |   2016-09   |   1   |
  |     2      |   2016-09   |   2   |
  |     3      |   2016-09   |   2   |
  </code></pre>