; z pivotdate (wybrany dateadd (wk, 17, "20100101") jako DayInWkNumX)
, keyDates (FirstDayNextWeek, FirstDay9WeeksAgo, FirstDayNextWeekOneYearAgo, FirstDay9WeeksAgoOneYearAgo)
(
wybiórka
DATEADD (wk, datediff (wk, (0), DayInWkNumX) +1,0),
DATEADD (wk, datediff (wk, (0), DayInWkNumX) - 9,0),
dateadd (yy, - (1), DATEADD (wk, datediff (wk, (0), DayInWkNumX) +1,0)),
dateadd (yy, - (1), DATEADD (wk, datediff (wk, (0), DayInWkNumX) - 9,0))
od pivotdate
)
wybrany Weeks10ToToday, Weeks10ToTodayOneYearAgo
od
(wybrany SUMA (somevalue) JAKO Weeks10ToToday od keyDates
wewnętrzny łączyć MyTable
na datefield >= FirstDay9WeeksAgo i datefield < FirstDayNextWeek="">= FirstDay9WeeksAgoOneYearAgo i datefield < FirstDayNextWeekOneYearAgo="">
|