In SQL server, I want to achieve sum of transactions spent on a monthly basis for the past 6 months. Below is the query that I have written
with filter_6month_transactions as (
SELECT
emplid,
format(transactiondate, 'yyyyMM') transactionmonth,
expenseamountreimbursementcurrency,
reimbursementcurrency,
CAST(DATEADD(m, -6, GetDate()) AS date) report_start_date,
DENSE_RANK() OVER(ORDER BY format(transactiondate, 'yyyyMM')) Rank,
er.exchangerate
FROM Concur_Expenses_CC_HighLimit_UDA e
LEFT join exchange_rates er
ON e.ReimbursementCurrency = er.FromCurrency
WHERE paymenttype LIKE '