My query is as follows:
I must make a query that adds the prices grouped by several concepts, then, insert those results in the totals column, only when the quantity is different from 0.
It would be like this:
Precio Departamento Unidad Mes Cantidad_item
3 a 1 ene 1
2 a 1 ene 0
12 a 1 feb 1
10 a 1 feb 0
1 a 2 mar 1
8 a 2 mar 0
That is, a select sum precio group by departamento, unidad, mes
etc is done.
Up there fantastic. What I do not know is how to get the results of each group to be inserted in the row of totals where the amount of items
of each group is different from 0 (when I make the groupings, only one record remains where quantity is different from 0 )
There should be something like this:
Precio Departamento Unidad Mes Cantidad_item Total
3 a 1 ene 1 5
2 a 1 ene 0
12 a 1 feb 1 22
10 a 1 feb 0
1 a 2 mar 1 9
8 a 2 mar 0