; con pivotdate come (selezionare il dateadd (settimana, 17, “20100101„) come DayInWkNumX)
, keyDates (FirstDayNextWeek, FirstDay9WeeksAgo, FirstDayNextWeekOneYearAgo, FirstDay9WeeksAgoOneYearAgo)
come (
prescelto
DATEADD (settimana, datediff (settimana, 0, DayInWkNumX) +1.0),
DATEADD (settimana, datediff (settimana, 0, DayInWkNumX) - 9.0),
dateadd (yy, - 1, DATEADD (settimana, datediff (settimana, 0, DayInWkNumX) +1.0)),
dateadd (yy, - 1, DATEADD (settimana, datediff (settimana, 0, DayInWkNumX) - 9.0))
da pivotdate
)
selezionare Weeks10ToToday, Weeks10ToTodayOneYearAgo
da
(SOMMA prescelta (somevalue) COME Weeks10ToToday dai keyDates
interno unire MyTable
sul >= FirstDay9WeeksAgo del datefield e sul datefield < FirstDayNextWeek="">= su FirstDay9WeeksAgoOneYearAgo e su datefield < FirstDayNextWeekOneYearAgo="">
|