1
I want to sum up the column Value that is of the type Varchar2, I know that to use the SUM() I also have to use the GROUP BY, only that I am not able to make the sum. I don’t know which fields I have to put on GROUP BY.
SELECT DISTINCT z.sales_office AS kam, z.customer,g.sales_order,
d.nfnum, d.vlr_liq_nf AS valor FROM TPL_GUARDA g
LEFT JOIN TPL_COLETAS c ON g.SALES_ORDER = c.SALES_ORDER
LEFT JOIN humo h ON h.HANDLING_UNIT = g.handling_unit
LEFT JOIN DANFE_DELIVERY dd ON dd.delivery = h.delivery
LEFT JOIN danfe d ON d.nfnum = dd.nfnum
LEFT JOIN zzcustmon z ON z.sales_order = g.sales_order
where c.dt_exp is null and d.nfnum is not null and z.delivery is not null
GROUP BY
What do you want as a result? Do you want the sum of each customer’s Value? Do you want the sum of each office’s Value?
– Matheus Ribeiro
I want to sum all the values of the column VALUE(d.vlr_liq.nf). I did the same as the friend commented right down, but it didn’t work.
– Guilherme Wayne