In below query, I am trying to fetch previous month results for last 12 months and I dont want to create 12 variables for all previous months.
so in below query i want to give column header lm as previous month coming from $month which is set in variable.
select month, segment as segment, sum(final_chargeback_price_after_credit) as lm1
from azure_monthly_chargeback where month = TO_DATE(‘$Month’,‘Mon YYYY’) - interval ‘1 month’
Below is the screenshot. presently other column headers are coming from variables base don $Month
Can anyone help on this query