title: SQL - Latest date based on action
body: <p>I have several rows in a single table as follows:</p>
  
  <p><code>[id], [date1], [action1], [date2], [action2], [date3], [action3], [date4], [action4]</code></p>
  
  <p>and for each row want to return the latest date when the action (which is defined by a single letter) matches the desired code.</p>
  
  <p>I suspect I will need to use the MAX() function somewhere, but not sure how to start?</p>