select case when date3 is null and date2 is not null then (datediff(dd,date2,getDate()))+(datediff(dd,date1,date2))/365 when date3 is not null and date2 is null then (datediff(dd,date1,date3))/365 end as day
from 表
select case when date3 is null then (case when date2 is not null then ((Now-date2)+(date2-date1))/365) else (case when data2 is not null then (date3-date1)/365) end as day from table where.....