我有以下查询,它使用 CASE 语句。无论如何要添加到 where 子句 WHERE IsBusinessDayFinal = 0 中吗?不使用临时表?
非常感谢!
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;