title: How many customers upgraded from Product A to Product B?
body: <p>I have a "daily changes" table that records when a customer "upgrades" or "downgrades" their membership level. In the table, let's say field 1 is customer ID, field 2 is membership type and field 3 is the date of change.  Customers 123 and ABC each have two rows in the table.  Values in field 1 (ID) are the same, but values in field 2 (TYPE) and 3 (DATE) are different. I'd like to write a SQL query to tell me how many customers "upgraded" from membership type 1 to membership type 2 how many customers "downgraded" from membership type 2 to membership type 1 in any given time frame.</p>
  
  <p>The table also shows other types of changes.  To identify the records with changes in the membership type field, I've created the following code:</p>
  
  <pre><code>SELECT *
  FROM member_detail_daily_changes_new
  WHERE customer IN (
      SELECT customer
      FROM member_detail_daily_changes_new
      GROUP BY customer
      HAVING COUNT(distinct member_type_cd) &gt; 1)
  </code></pre>
  
  <p>I'd like to see an end report which tells me:</p>
  
  <p>For Fiscal 2018, 
  X,XXX customers moved from Member Type 1 to Member Type 2 and 
  X,XXX customers moved from Member Type 2 to Member type 1</p>