title: SQL: Calculating the Max date across multiple tables
body: <p>I am trying to find the max date across multiple columns (in multiple tables). I have an SQL query that I think is almost workable, but am having a hard time debugging it. The problem is that it never returns anything. Any ideas on what I'm doing incorrectly? I don't get any errors, just an empty row "maxdate."</p>
  
  <p>Here's my query:</p>
  
  <pre><code>SELECT
  (
      SELECT MAX(dates) FROM
      (
          SELECT dates = t1.UpdateDate
          UNION ALL
          SELECT dates = t2.UpdateDate
          UNION ALL
          SELECT dates = t3.UpdateDate
          UNION ALL
          SELECT dates = t4.UpdateDate
      ) as dateAcrossColumns
  ) as maxdate
  
  FROM table1 as t1
  
  join table2 as t2 on t1.ID = t2.ID
  join table3 as t3 on t1.ID = t3.ID
  join table4 as t4 on t1.ID = t4.ID
  join table5 as t5 on t1.Status = t5.Status
  
  WHERE t1.id = @param and t5.status &lt;&gt; 3
  </code></pre>