我目前选择当前月份最后年份的数据。这适用于
SELECT cast(CREATED as date) AS DATE, COUNT([ID]) AS BOOKINGS, SUM([TOTCOST]) AS Sales
from BOOKING
WHERE
CREATED >= DATEADD(month, datediff(month, 0, getdate())-12, 0)
AND
CREATED < DATEADD(month, datediff(month, 0, getdate())-11, 0)
GROUP BY cast(CREATED as date)
ORDER BY cast(CREATED as date)
但是,我想在2014年7月2日至2014年8月1日之间返回,而不是在7月1日至31日之间返回。那个月当天有效+1天。 这可能吗?
答案 0 :(得分:0)
是的,只需在计算结果中加1即可。
UPDATE animalTable SET cDescription = "cat" WHERE CodeID = 1 AND cDescription != "cat"