I have a query that looks like:
SELECT
col1
,...
,col3
,(SELECT col3 FROM table where <clause>) AS MinPickTime
,(SELECT col3 FROM table where <clause>) AS MaxPickTime
,DATEDIFF(d, MinPickTime, MaxPickTime)
FROM table
However the DATEDIFF line does not like the alias columns.
In short, how do I give DATEDIFF an alias column derived by a subquery?