title: How do I query how many items have changed the status between datetime?
body: <p>I have a history table like this</p>
  <pre><code>id, name, is_active, mod_date
  1, 'name1', 0, 2020-06-09 21:00:00
  1, 'name1', 1, 2020-06-09 22:00:00
  2, 'name2', 1, 2020-06-09 20:00:00
  2, 'name2', 0, 2020-06-09 20:10:00
  2, 'name3', 1, 2020-06-09 20:20:00
  3, 'name4', 0, 2020-06-09 20:00:00
  </code></pre>
  <p>The table above is the example of the data. It means <code>id1</code> changed the status from 0 to 1 and <code>id2</code> change the status from 1 to 0 at the mod_date and later change the name to <code>name3</code> as well as flip the <code>is_active</code> back to 1. However, <code>id3</code> is only a name change to <code>name4</code></p>
  <p>I would like to query how many items have change is_active columns. So the answer would be</p>
  <pre><code>id1, 1
  id2, 2
  </code></pre>
  <p><code>id1</code> change the is_active column 1 time and <code>ids2</code> twice.</p>
  <p>Is this even possible in SQL? I'm starting with something like this but I'm not sure how to tell SQL to compare the previous row.</p>
  <pre><code>select c.id, c.is_active, c.mod_date
  from customer_h c
  where c.mod_date between '2020-06-09' and '2020-06-10'
  order by c.ad_id, c.mod_date
  </code></pre>