我有以下
(SELECT
ts.PID,
tt.ID,
tt.ItemOrder,
tt.DisplayVal as Task,
tt.Responsible as ResParty,
tt.DaysDue,
DATEADD(day, tt.DaysDue, PgStartDate) as DueDate,
ts.spate As ActualDate ,
ps.PgStartDate as ProgramDate
FROM tblTimeline tt
CROSS JOIN tblSers ts
JOIN PG ps ON ps.PID = ts.PId
WHERE tt.ID = 2
AND ps.cancelled = 0 )
t1
INNER JOIN(
SELECT
ts.PID,
max(DATEADD(day, tt.DaysDue, PgStartDate)) as DueDate
FROM tblTimeline tt
CROSS JOIN tblSers ts
JOIN PG ps on ps.PID = ts.PId
WHERE tt.ID = 2
AND ps.cancelled = 0)
t2
ON t1.PID = t2.PID
AND t1.DueDate = t2.DueDate
在t1
中,我所拥有的是PID, DueDate
给定行的重复项。
我喜欢为每个获得完整的行PID
,我喜欢显示具有 Max 的行DueDate
。
我在 t1, t2 附近得到不正确的语法