title: (T-SQL) How to query an audit table, and find changes between 2 dates
body: <p>The audit table looks like this: </p>
  
  <pre><code>Audit ID    VendorID     PaymentType     CreateDateUTC
   999        8048         2               2017-10-30-08:84:24
  1000        1234         5               2017-10-31-01:17:34
  1001        8048         7               2017-10-31-01:17:45
  1002        1234         5               2017-10-31-01:17:53
  1003        1234         7               2017-10-31-01:18:23
  1004        1234         5               2017-11-01-01:18:45
  </code></pre>
  
  <p>In this example, you can see that say - VendorID 1234 started as PaymentType 5, then had another entry where it's still 5 (the audit table records additional changes not relevant to my query), then it changes to 7, but then back to 5.</p>
  
  <p><strong>Say I'd want to answer the question: 'Between now and date X, these VendorIDs had a change in PaymentType'.</strong> A bonus would be - this was the previous PaymentType.</p>
  
  <p>Expected Results:</p>
  
  <pre><code>VendorID  PaymentType  Prev_PaymentType
  8048      7            2
  </code></pre>
  
  <p>So say if I queried between now and 10-31-01:00:00, I'd want it to return VendorID 8048 as having changed (and as a bonus, that it's previous PaymentType was 2), but VendorID 1234 shouldn't show up, since at 2017-10-31-01:00:00 it was a 5, and now is still a 5, despite the intermittent changes. </p>
  
  <p>How would one go about querying the VendorIDs whose payment type changed between 2 dates? </p>
  
  <p>Thanks!</p>