I need to write a report to show transaction qty from previous months.
I have the following which works fine until the current month is January
SELECT 'Previous1' as Period, TrnYear,TrnMonth, PartCategory, StockCode, Description, Qty, DrawOfficeNum, WarehouseToUse, JobClassification
FROM vwUsagePurchPress_1YearHistory
WHERE (TrnYear = DATEPART(Year, GETDATE())) AND (TrnMonth = DATEPART(Month, GETDATE())-1)
How do I get it to read December from previous year if current month = January