希望您能提供帮助,我需要总计 TotalCapacity 列,以便根据 Where 语句给我一年的总计。我还需要看到彼此相邻的不同年份。谢谢
SELECT
Capacity.StartDate,
Capacity.EndDate,
DATEDIFF(d, Capacity.StartDate, Capacity.EndDate) + 1 AS DaysOpen,
Capacity.Capacity,
(DATEDIFF(d, Capacity.StartDate, Capacity.EndDate) + 1) * Capacity.Capacity AS TotalCapacity,
FROM
Capacity
WHERE
Capacity.StartDate >= '01 Jan 2010'
AND Capacity.EndDate <= '31 Dec 2010'