title: How to find max value of column with NULL being included and considered the max
body: <p>I have a table with a column of dates which includes dates and <code>NULL</code> values. I am trying to figure out a way to find the MAX <code>Date</code>, per <code>ID</code>, or if there is a <code>NULL</code> value, then to return <code>NULL</code> instead.</p>
  
  <p>So for example:</p>
  
  <pre><code>ID    Date
  1     2014-01-01
  1     2014-02-01
  1     2014-03-01
  2     2014-02-01
  2     NULL
  3     NULL
  4     2014-03-01
  </code></pre>
  
  <p>So what I am trying to yield is:</p>
  
  <pre><code>1 = 2014-03-01
  2 = NULL
  3 = NULL
  4 = 2014-03-01
  </code></pre>
  
  <p>As of right now I am using something like this:</p>
  
  <pre><code>NULLIF(MAX(COALESCE(n.[SentDate], '12/16/9997')),'12/16/9997') AS [MaxSentDate]
  </code></pre>
  
  <p>I am 99% sure that no one will ever put in a date of <code>12/16/9997</code>, but I would like to come up with a proper solution rather than using a hackish one like this.</p>