How to display the leading zero's in a number of oracle

前端 未结 4 1890
伪装坚强ぢ
伪装坚强ぢ 2021-01-06 04:02

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

4条回答
  •  滥情空心
    2021-01-06 04:40

    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;
    

提交回复
热议问题