1

我需要执行以下操作:

    Select ProID from Pros ps where ps.ProId = '102-C01-1299'
    and  ConfirmDate > DATEADD(DAY, (select tt.DaysDue from tblTaskTimeline tt where Task   = 'TaskInfo') as days,ps.ProgStartDate) 

请注意对于 DATEADD 函数,我需要动态获取第二个参数。请注意 tt.DaysDue 返回一个整数值。

我收到一条消息说 DATEADD 需要 3 个参数。

4

2 回答 2

1

为什么不先创建一个参数?

declare @days int
set @days = (select tt.DaysDue from tblTaskTimeline tt where Task   = 'TaskInfo')

Select ProID 
from Pros ps 
where ps.ProId = '102-C01-1299'
    and  ConfirmDate > DATEADD(DAY, @days, ps.ProgStartDate)

如果您不能使用参数,那么以下应该可以工作:

Select ProID 
from Pros ps 
where ps.ProId = '102-C01-1299'
    and  ConfirmDate > DATEADD(DAY, (select tt.DaysDue from tblTaskTimeline tt where Task = 'TaskInfo'), ps.ProgStartDate)
于 2012-08-02T17:04:48.083 回答
0

删除“ as days”,它应该可以工作。

于 2012-08-02T17:05:20.977 回答