Hello
I am trying to create a view and getting Invalid column name error when executing this Select statement
CREATE VIEW [dbo].[test]
AS
SELECT
ProjectReturn_Detail.DepartmentID,
ProjectReturn_Detail.QTRID,
ProjectReturn_Detail.ProjectID,
ProjectReturn_Detail.ProjReturnID,
Min(CASE
WHEN [ManMilestoneID]=2 THEN [OriginalBaselineDate]
ELSE Null
END
)
AS EndDateBase,
Min(CASE
WHEN [ManMilestoneID]=2 THEN [LatestBaselineDate]
ELSE Null
END
)
AS EndDateLastBase,
Min(CASE
WHEN [ManMilestoneID]=1 THEN [OriginalBaselineDate]
ELSE NULL
END
)
AS StartDateBase,
Min(CASE
WHEN [ManMilestoneID]=1 THEN [LatestBaselineDate]
ELSE NULL
END
)
AS StartDateLastBase,
--------------------------------------------------------------------------------------------------------------------------------------------------------
CASE
WHEN [EndDateLastBase] Is Null THEN datediff(day,[EndDateBase],[StartDateBase])/365.25
ELSE datediff(day, [EndDateLastBase],[StartDateBase])/365.25
END
AS ProjectDuration
---------------------------------------------------------------------------------------------------------------------------------------------------------
FROM
ProjectReturn_Detail
INNER JOIN (MandatoryMilestone
INNER JOIN Milestone ON MandatoryMilestone.ManMilestoneID = Milestone.MandatoryMilestoneID)
ON ProjectReturn_Detail.ProjReturnID = Milestone.ProjReturnID
WHERE (((Milestone.MandatoryMilestoneID)=1 Or (Milestone.MandatoryMilestoneID)=2 Or (Milestone.MandatoryMilestoneID)=3 Or (Milestone.MandatoryMilestoneID)=13))
GROUP BY ProjectReturn_Detail.DepartmentID, ProjectReturn_Detail.QTRID, ProjectReturn_Detail.ProjectID, ProjectReturn_Detail.ProjReturnID
I am trying to create a view and getting Invalid column name error when executing this Select statement
CREATE VIEW [dbo].[test]
AS
SELECT
ProjectReturn_Detail.DepartmentID,
ProjectReturn_Detail.QTRID,
ProjectReturn_Detail.ProjectID,
ProjectReturn_Detail.ProjReturnID,
Min(CASE
WHEN [ManMilestoneID]=2 THEN [OriginalBaselineDate]
ELSE Null
END
)
AS EndDateBase,
Min(CASE
WHEN [ManMilestoneID]=2 THEN [LatestBaselineDate]
ELSE Null
END
)
AS EndDateLastBase,
Min(CASE
WHEN [ManMilestoneID]=1 THEN [OriginalBaselineDate]
ELSE NULL
END
)
AS StartDateBase,
Min(CASE
WHEN [ManMilestoneID]=1 THEN [LatestBaselineDate]
ELSE NULL
END
)
AS StartDateLastBase,
--------------------------------------------------------------------------------------------------------------------------------------------------------
CASE
WHEN [EndDateLastBase] Is Null THEN datediff(day,[EndDateBase],[StartDateBase])/365.25
ELSE datediff(day, [EndDateLastBase],[StartDateBase])/365.25
END
AS ProjectDuration
---------------------------------------------------------------------------------------------------------------------------------------------------------
FROM
ProjectReturn_Detail
INNER JOIN (MandatoryMilestone
INNER JOIN Milestone ON MandatoryMilestone.ManMilestoneID = Milestone.MandatoryMilestoneID)
ON ProjectReturn_Detail.ProjReturnID = Milestone.ProjReturnID
WHERE (((Milestone.MandatoryMilestoneID)=1 Or (Milestone.MandatoryMilestoneID)=2 Or (Milestone.MandatoryMilestoneID)=3 Or (Milestone.MandatoryMilestoneID)=13))
GROUP BY ProjectReturn_Detail.DepartmentID, ProjectReturn_Detail.QTRID, ProjectReturn_Detail.ProjectID, ProjectReturn_Detail.ProjReturnID