title: Mysql sum of column by week and divided sum value of the last week
body: <p>In my database, data is stored by day. I want to sum the value by week and then divided the value by the sum value of the last week. Is it possible achieved by SQL?
  Example :</p>
  
  <pre><code>   Table  Structure
     ItemCode   Amount         DatebyDay
     01         500           20170815
     01         500           20170816
     ...
     01         500           20170819
     01         1000           20170821
     01         1000           20170822
     ...
     01         1000           20170825
      ...
     02         2000           20170815
     02         2000           20170816
     ...
     02         2000           20170819
     02         3000           20170821
     02         3000           20170822
     ...
     02         3000           20170825
     ....
  </code></pre>
  
  <p>My expected result is:</p>
  
  <pre><code> 01  2                //(1000*5)/(500*5)
   02  1.5              //(3000*5)/(2000*5)
  </code></pre>
  
  <p>So any one have any idea how do do this.Thank you.</p>