Get the percentage between 2 in a Dynamic SQL query

0

Good afternoon I'm trying to get the % between months compared to the year after, so in month 1/2016 value was 2115.00 month 01/2017 value was 3511.00 take the percentage between these 2 and make the margin / percentage the output would be + - so

year | value | %

1/2016 | 2115.00 | 24

1/2017 | 3511.00 | 24
24 - this would be the value + - calculated percentage between month 1 of 2016 and 1/2017

In this link I gave an example to try to express better: SQL Fiddle

Using SQL SERVER 2014

If someone can help is for company report the fields will be filled by variables from initial month, final month and also per year starting year and final year always comparing with the previous year 2015 compares with 2016, 2016 compares with 2017, 2018 compares with 2017.

    
asked by anonymous 29.08.2018 / 17:26

0 answers