title: flatten SQL columns based on modification timestamp
body: <p>I have (to access) a table with dozens of columns.
  The rows contain deltas compared to latest version.<br />
  Each row represents a person that made the changes.</p>
  <p>e.g.</p>
  <pre><code>id    item col_a col_b col_c (many more columns) modified_by  modified_on
  123   1    A     one   red                                 1  2017-12-01 10:00
  721   1          three                                     4  2020-03-12 10:00
  974   1    B     two                                       5  2019-10-06 10:00
  </code></pre>
  <p>Would like to receive:</p>
  <pre><code>      item col_a col_b col_c (many more columns) modified_on
        1    B     three red                       2020-03-12 10:00
  </code></pre>
  <p>And optional: <code>created_on: 2017-12-01 10:00</code> and <code>last_updated_by: 4</code>.</p>
  <p>Note: the rows are not necessarily in order (row 721 was e.g. created in 2018 and updated in 2020).<br />
  For each column the max modified_on should be used.</p>
  <p>Want to avoid something like this</p>
  <pre><code>select item,
    &lt;&quot;max&quot; of col_a&gt;,
    &lt;&quot;max&quot; of col_b&gt;,
    ...
    &lt;&quot;max&quot; of col_xyz&gt;
  from mytable
  group by item
  </code></pre>
  <p>as the table has dozens of columns and it could be the table columns change over time, which makes it tricky to maintain.</p>
  <p>DB is sqlsrv, but plain SQL is preferred.</p>
  <p>How can I efficiently flatten the DB?</p>