1
I need to take the total value of the VOL field (image below), it is already generated by the SUM function. It can be in another query. All periodic tithes are required.
ex: total = VOL(7,6890028) -> sum of the 4 rows in column VOL
1
I need to take the total value of the VOL field (image below), it is already generated by the SUM function. It can be in another query. All periodic tithes are required.
ex: total = VOL(7,6890028) -> sum of the 4 rows in column VOL
4
Something like :
Select campo1,
sum(valor1) valor
from tabela
group by cube (campo1)
Cube () --- that there
For other useful functions search for "Analytic functions" https://docs.microsoft.com/pt-br/sql/t-sql/queries/select-over-clause-transact-sql?view=sql-server-2017
1
You can do something about it
Select sum(a.VOL) from (
*SUA QUERY AQUI*) a
went wrong, "15,3780056" when it should go "7,6890028"
It looks like it’s adding up twice. There’s no improper multiple in your query?
Browser other questions tagged sql sql-server query sum
You are not signed in. Login or sign up in order to post.
It is not clear your doubt, need to detail more
– Diego Marques
Takes the
GROUP BY
. If you want to add them all up, there’s no reason to discriminateVolumes
.– rbz
I want the sum of all rows in column VOL
– Danielle Arruda torres
But you’re grouping by
Volumes
, it is illogical what you are saying. You want to add all, and repeat in the fieldVOL
, and grouped byVolumes
. Is your concept wrong, or is not clear the doubt.– rbz
Try GROUP BY CUBE (NF.VOLUMES)
– Motta
@Motta even with CUBE or ROLLUP, I don’t think that was her idea. But, I’ll wait for more details.
– rbz
first I list Vol of each invoice(each row is a note). But now I need the overall total (sum of volumes of all notes). Can be in another query.
– Danielle Arruda torres
@Motta - it worked... That’s right... Thank you "Try GROUP BY CUBE (NF.VOLUMES)"
– Danielle Arruda torres
@Motta put in the answer I mark as the right one
– Danielle Arruda torres