How to realize the sum of values I multiplied?

Asked

Viewed 41 times

1

I performed an operation that multiplies the amount of values by the unit value of each one, obtaining the total value per product. How could I add up the total values of all products? I tried with a Sum within a Sum...

EDIT1: I tried to use Rollup but ended up breaking the 100mb limit

  • 2

    You could post your SQL code to better indicate you the use of sum. Depending on the fields of select, can display a group by. And you need to specify if it is SQL Server, Mysql, Oracle etc.

1 answer

0

I believe it’s something like :

select cod_produto , sum(valor_unitario * quantidade) valor_total
from   vendas
group by cod_produto 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.