I want to summarise the sum of sales.quantity by week, and to show the week number even if there are no sales.
I have setup a weeks table with 1-54 in there to use an ou
I prefer this method versus a sub-select
SELECT Weeks.WeekNum, SUM(sales.quantity) AS sales FROM Weeks LEFT OUTER JOIN sales ON (Weeks.WeekNum = DATEPART(week, sales.transDate) AND sales.transDate BETWEEN @fromDate AND @toDate) GROUP BY Weeks.WeekNum