I have a query that runs against several tables and return all records for a date range. I need a report that has this information on it for 4 different date ranges.
Last Month
Year to Date
Last Year Last Month
Last Year Year to Date
Assuming you are adding numbers. Try something like
Select F1, F2, F3.....
, Iif( RecordDate between BeginMonth and End_Month), AmountField, 0) as LastMonth
, Iif( RecordDate >= BeginYear), AmountField, 0) as YTD
, Iif( RecordDate between BeginMonthLastYear and End_MonthLastYear), AmountField, 0) as LastYearLastMonth
,Iif( RecordDate between BeginLastYear and EndLastYear), AmountField, 0) as LastYear
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.