title: SQL Columns to rows with last 12 months of data
body: <p>I have a sql table with monthly consumption amounts. I would like to convert the columns to rows by cust_no and show only the last 12 months of consumption. There are many customers with years of consumption data. I would like the data to refresh as new consumption readings come in and as time goes on with the newest reading, then the one before that, and so on. What's the best way to do this?</p>
  
  <hr>
  
  <pre><code>cust_no cons read_dt
     1    1    2/28/2017 0:00
     1    2    3/31/2017 0:00
     1    2    5/1/2017 0:00
     1    2    6/1/2017 0:00
     1    2    6/30/2017 0:00
     1    2    7/31/2017 0:00
     1    2    8/29/2017 0:00
     1    3    9/29/2017 0:00
     1    2    10/31/2017 0:00
     1    2    12/1/2017 0:00
     1    2    1/2/2018 0:00
     1    3    2/1/2018 0:00
     1    2    3/2/2018 0:00
     2    1    12/21/2016 0:00
     2    0    1/20/2017 0:00
     2    0    2/21/2017 0:00
     2    1    3/24/2017 0:00
     2    1    4/24/2017 0:00
     2    2    5/25/2017 0:00
     2    2    6/26/2017 0:00
     2    1    7/25/2017 0:00
     2    1    8/24/2017 0:00
     2    2    9/25/2017 0:00
     2    2    10/26/2017 0:00
     2    2    11/27/2017 0:00
     2    1    12/26/2017 0:00
     2    2    1/26/2018 0:00
     2    2    2/26/2018 0:00
  </code></pre>