1
I want to sum up the column Value, I know that to use SUM() I also have to use GROUP BY, only I’m 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
I tried to execute the code and gave the error ORA-01722: invalid number.
– Guilherme Wayne
d.vlr_liq_nf
is not a numerical field?– rLinhares
It’s the prices of the materials that stay on it
– Guilherme Wayne
@Guilhermewayne, could share the definitions of the column fields in the question, remembering that the summation fields only work in numerical fields.
– Confundir
The field I’m trying to add is varchar2 type. I just looked here. I thought it was numeric. It has how to make the sum of it?
– Guilherme Wayne
@Guilhermewayne, the answer (edited) helped??
– rLinhares
The TO_NUMBER did not work, after breaking the head trying, I found that the oracle does not treat the comma as separation of values, the correct is to use point. So as much as I tried to convert the value with TO_NUMBER, it wouldn’t work. So I used REPLACE to replace the comma by stitch, and then it worked
– Guilherme Wayne
@Guilhermewayne, I get it. well, I’ll change the answer and add that you went through, but if you prefer, post an answer saying what you solved and mark as accepted.. ideal is that the question don’t go unanswered
– rLinhares
@You just did that
– Guilherme Wayne