SQL SERVER - Using DATEDIFF with subquery column -
i have query looks like:
select col1 ,... ,col3 ,(select col3 table <clause>) minpicktime ,(select col3 table <clause>) maxpicktime ,datediff(d, minpicktime, maxpicktime) table
however datediff line not alias columns.
in short, how give datediff alias column derived subquery?
use derived tables concept access alias name.
select col1 ,... ,col3, minpicktime, maxpicktime , datediff(d, minpicktime, maxpicktime) ( select col1 ,... ,col3 ,(select col3 table <clause>) minpicktime ,(select col3 table <clause>) maxpicktime table )z
Comments
Post a Comment