title: MySQL show this year value and last year from same table
body: <p>I'm pretty new to mysql, but I have a table that looks like this:</p>
  
  <pre><code>+----+------+-------+-------+------+
  | id | year | month | total | cost |
  +----+------+-------+-------+------+
  |  1 | 2011 | Dec   |  2000 | 2048 |
  |  2 | 2012 | Jan   |  2675 | 2738 |
  |  3 | 2012 | Feb   |  2685 | 2749 |
  |  4 | 2012 | Mar   |  1787 | 1830 |
  |  5 | 2012 | Apr   |  1547 | 1584 |
  |  6 | 2012 | May   |   847 |  867 |
  |  7 | 2012 | Jun   |   621 |  636 |
  |  8 | 2012 | Jul   |   610 |  624 |
  |  9 | 2012 | Aug   |   659 |  675 |
  | 10 | 2012 | Sep   |   828 |  848 |
  | 11 | 2012 | Oct   |  1420 | 1454 |
  | 12 | 2012 | Nov   |  1608 | 1646 |
  | 13 | 2012 | Dec   |  2721 | 2786 |
  | 14 | 2013 | Jan   |  2636 | 2699 |
  | 15 | 2013 | Feb   |  2266 | 2320 |
  | 16 | 2013 | Mar   |  2351 | 2407 |
  | 17 | 2013 | Apr   |  1497 | 1532 |
  | 18 | 2013 | May   |   819 |  838 |
  | 19 | 2013 | Jun   |   668 |  684 |
  | 20 | 2013 | Jul   |   580 |  594 |
  | 21 | 2013 | Aug   |   623 |  638 |
  | 22 | 2013 | Sep   |   790 |  808 |
  | 23 | 2013 | Oct   |  1146 | 1173 |
  | 24 | 2013 | Nov   |  1581 | 1618 |
  +----+------+-------+-------+------+
  </code></pre>
  
  <p>I need a query that gives me the results (cost) as this:</p>
  
  <pre><code>+-------+-------+------+
  | month |  2012 | 2013 |
  +-------+-------+------+
  | Sep   |   848 |  808 |
  | Oct   |  1454 | 1173 |
  | Nov   |  1646 | 1618 |
  +-------+-------+------+
  </code></pre>
  
  <p>I'm following the electrical consumption and need to see month this year and previous year. Any ideas?</p>