I need to update a column according to the contents of two other columns, for example, I have two tables, the suprimentos
table and the estoque
table,
Supplies table
codigoSuprimento
capacidadeSuprimento
Inventory table
codigoSuprimento
capacidadeUsada
percentualUsado
Let's say that in the suprimentos
table I have the following registry:
codigoSuprimento | capacidadeSuprimento
1 | 1000
And in the table estoque
the following register:
codigoSuprimento | capacidadeUsada | percentualUsado
1 | 300 | X
My need is to create a function so that the percentualUsado
column is populated according to capacidadeUsada
over capacidadeSuprimento
. It would be capacidadeUsada
x 100
/ capacidadeSuprimento
. But I do not know how to do this in a Function , put that content in parameters to be able to perform that calculation that is an unknown to me.