Klausa where WHERE (sales.transDate BETWEEN @fromDate AND @toDate)
akan menghapus setiap minggu tanpa penjualan. Anda mungkin perlu melakukan subkueri untuk menarik transaksi dan kemudian menggabungkannya ke tabel minggu Anda.
SELECT Weeks.WeekNum, SUM(sales.quantity) AS sales
FROM Weeks LEFT OUTER JOIN
(
SELECT *
FROM sales
WHERE (sales.transDate BETWEEN @fromDate AND @toDate)
) sales
ON Weeks.WeekNum = DATEPART(week, sales.transDate)
GROUP BY Weeks.WeekNum