title: SQL SERVER - Using DATEDIFF with subquery column
body: <p>I have a query that looks like:</p>
  
  <pre><code>SELECT
      col1
      ,...
      ,col3
      ,(SELECT col3 FROM table where &lt;clause&gt;) AS MinPickTime
      ,(SELECT col3 FROM table where &lt;clause&gt;) AS MaxPickTime
      ,DATEDIFF(d, MinPickTime, MaxPickTime)
  FROM table
  </code></pre>
  
  <p>However the DATEDIFF line does not like the alias columns.</p>
  
  <p>In short, how do I give DATEDIFF an alias column derived by a subquery?</p>