I have Sales Table with the following fields.
year
month
samount
Requirement is to check if current month's sales amount is higher than the previous year sales amount for the same month.
I tried with the following sql but seems to be missing some comparison. Please advise
select year, month, samount, samount-lag(samount,12) over (order by year,month) as diff_cur_prev_sales from sales;