I have an oracle column(artnr) contains a length of 1 which is of type number(9). I want to update the number as following...
Example :
If number is 0 then i
In my case the goal was calculate the sum of the values of the different currencies, but the issue was created by the data type of the field VALUE that is VARCHAR2(255 BYTE). I have found this solution, for handle the problem of the leading zero:
SELECT ID_OUT
, CASE WHEN REPLACE(SUM(REPLACE(VALUE, '.', ',')), ',', '.') LIKE '-.%' THEN REPLACE(REPLACE(SUM(REPLACE(VALUE, '.', ',')), ',', '.'), '-.', '-0.')
WHEN REPLACE(SUM(REPLACE(VALUE, '.', ',')), ',', '.') LIKE '.%' THEN REPLACE(REPLACE(SUM(REPLACE(VALUE, '.', ',')), ',', '.'), '.', '0.')
ELSE REPLACE(SUM(REPLACE(VALUE, '.', ',')), ',', '.')
END AS VALORE
, LOB
, 'TOTAL' CURRENCY
, COUNTRY
FROM QRT_OUT_DATI
WHERE (CURRENCY != 'Total' AND CURRENCY != 'TOTAL')
GROUP BY ID_OUT, LOB, COUNTRY, CURRENCY
ORDER BY LOB;