Good night, I have a table with 4 fields and through them I make some calculations and create a new field to show these same results ... The problem is that later I want to go get those results and I do not know how to redeem them. / p>
declare @mesAtual as int = (6)
select mes,
valor,
periodicidade ,
cast(valor / periodicidade as decimal(18,2)) as ValorMes,
case when @mesAtual > mes then @mesAtual - mes
when @mesAtual < mes then (periodicidade - (mes - @mesAtual)) + 1
when @mesAtual = mes then 0 end as Diferenca
from tblPrevista