I am trying to group values (sales data) by week in SQL Server. For items with no sales in a certain week, I still want to get the week number and year, with a sum of 0.
The sales ledger table has computed columns for year and week number, by which I group.
Right now my Query looks like this:
select ItemNumber, sum(Amount), year, week
from JournalPosition
group by week, year, ItemNumber
order by ItemNumber asc, year desc, week desc
What would be an efficient way to accomplish what i want without having to implement a data warehouse? (Stored procedure or temporary table would be fine for me)