1

我的问题是它们都住在同一张桌子上。我如何能够从他们那里获得经过验证的日期差异?我的最终目标是获得从顶部到底部所需的平均天数。以及转化率。

select *  from contactworkflow where contactworkflow.contactkey = contactworkflow.contactkey
       AND   (    contactworkflow.wfstagekey = 2
                AND contactworkflow.wftaskkey = 74) 

两者都有不同的 wfdate,我需要获得差异。我打算做一个datefiff,但不知道怎么写。

select *  from contactworkflow where contactworkflow.contactkey = contactworkflow.contactkey
   AND   (    contactworkflow.wfstagekey = 4
            AND contactworkflow.wftaskkey = 49) 
4

1 回答 1

2

对于 datediff 部分:

declare @date1 datetime, @date2 datetime

select @date1 = wfdate
from contactworkflow
where contactworkflow.contactkey = contactworkflow.contactkey
AND contactworkflow.wfstagekey = 2
AND contactworkflow.wftaskkey = 74

select @date2 = wfdate
from contactworkflow
where contactworkflow.contactkey = contactworkflow.contactkey
AND contactworkflow.wfstagekey = 4
AND contactworkflow.wftaskkey = 49

-- dd means difference in days
select datediff(dd, @date1, @date2)
于 2013-04-01T16:08:27.113 回答