Get the percentage in SQL Server

0

I have two quantities a total value and a value to date and I need to take the percentage, example:

ValorTotal = 66215
ValorALaFecha = 5524
Porcentaje = ?

At what percentage is the ValueAutumn equal to TotalTotal .

    
asked by ARR 27.07.2018 в 23:22
source

1 answer

2

Applying 3 simple ((x * 100.0) / total)

Porcentaje = ((ValorALaFecha * 100.0)/ValorTotal )

If there are two records of the same table

SELECT ValorTotal , ValorALaFecha , ((ValorALaFecha * 100.0)/ValorTotal )AS Porc from tabla
    
answered by 27.07.2018 / 23:27
source