我有以下查詢,它使用CASE語句。 無論如何要添加到where子句WHERE IsBusinessDayFinal = 0?不使用臨時表?SQL Server WHERE子句使用臨時列
非常感謝!
SELECT
ac.DateTimeValue,
CASE
WHEN pc.IsBusinessDay IS NOT NULL THEN pc.IsBusinessDay
ELSE ac.IsBusinessDay
END AS IsBusinessDayFinal,
ac.FullYear,
ac.MonthValue,
ac.DayOfMonth,
ac.DayOfWeek,
ac.Week
FROM
[dbo].[AdminCalendar] ac LEFT JOIN
[dbo].ProjectCalendar pc ON ac.DateTimeValue = pc.DateTimeValue AND pc.ProjectId = @projectId
WHERE ac.DateTimeValue >= @startDate AND ac.DateTimeValue <= @finishDate;
您可以使用子查詢? – 2009-12-12 02:43:27