I have 2 tables:
TableA is a calendar of all possible weeks we should have sales data for per company.
TableB has financial data for sales per company per week that have been reported.
TableA Columns
[cmp_code, Year, Week]
TAbleB Columns
[cmp_code, Year, Week, sales]
Query Criteria:
1) List weeks missing from TableB for Current year and previous year for all companies
2) List the previous year sales value for that company and week if it exists. (example cmp 1234 is missing week 13, 2013, so show the value of that week in 2012)
I've tried joins but I either get 0 values returned or millions of values returned. I just don't really know where to even start.
I'm very new to SQL and greatly appreciate any help offered. Thanks in advance.