title: "ROW_NUMBER() OVER (PARTITION BY" With Array of grouped items for History tracking
body: <p>I'm trying to create a reference table for a large dataset, where I need to match up data using the ID as the PK. However, I also need to manage the history of the alias changes associated with the ID, for analysis further down the line - Any help or suggestions are appreciated. I've left examples of the desired output below;</p>
  <p>Currently I am using this;</p>
  <pre><code>SELECT ID, Email FROM (
    SELECT ID, Email, EventDate, ROW_NUMBER() OVER (PARTITION BY ID
    ORDER BY EventDate DESC) recent_record FROM 
      (
      SOURCE TABLE
      )  
   ) WHERE recent_record = 1
  </code></pre>
  <p><a href="https://i.stack.imgur.com/cEr0b.png" rel="nofollow noreferrer">Example Output</a></p>