title: highest percentage growth
body: <p>I am using Postgres 9.6 and pgadmin 4.</p>
  
  <p>My question is as follows:</p>
  
  <p>Which segment had the highest percentage growth between 2014 and 2015? How much?</p>
  
  <p>this is a join between two tables</p>
  
  <p>table 1: <code>case_data_order</code></p>
  
  <ul>
  <li>create_timestamp- (timestamp) looks like this for example: 2014-01-01 10:12:20 </li>
  <li>purchase_amount- (bigint) the amount for purchase</li>
  <li>id - (numeric)-an id for a single purchase </li>
  <li>merchant_id - same as below. </li>
  </ul>
  
  <p>table 2: <code>case_data_merchant</code></p>
  
  <ul>
  <li>merchant_category (text) - this is where the difference segments are</li>
  <li>merchant_id-(bigint) an id for the merchant the purchase was made at</li>
  </ul>
  
  <p>I have tried several times but I don't know how to to it.</p>
  
  <pre><code>select merchant_category ((purchase_amount_2014-purhase_amount_2015)/purchase_amount_2014*100) 
  from (
      select sum(purchase_amount) as purchase_amount_2015 
      from case_data_order 
         natural join case_data_merchant 
      where create_timestamp between '2014-01-01' and '2014-12-31'
    group by merchant_category) as data_2015
  </code></pre>
  
  <p>natural join
  (select sum(purchase_amount) as purchase_amount_2014 
          from case_data_order 
             natural join case_data_merchant 
          where create_timestamp between '2015-01-01' and '2015-12-31
      group by merchant_category) as data_2014;</p>