title: SQL Server - Replacing NULL values with mode of column grouped by another column
body: <p>I have a table (call it <code>oldtable</code>) and the relevant columns are <code>name</code>, <code>group</code>, <code>zip code</code>. I have selected those into a new table (call that <code>newtable</code>). My issue is that some of the zip codes in the first table are NULL. I want to replace the NULL zip codes with the mode (most common value) of their <code>group</code>. </p>
  
  <p>For example, say a row in <code>newtable</code> looks like this:</p>
  
  <pre><code>Name   Group ZipCode
  Blah   G1    NULL
  </code></pre>
  
  <p>I want to replace that NULL with the most common zip code over all the people in G1 in <code>oldtable</code>. I am having trouble even getting started on pulling the mode of one column when grouped by another column.</p>
  
  <p>I am using Microsoft SQL Server 2016.</p>