Q:

Oracle - Format number with fullstop for thousand and comma for decimals

I've a number like this 3225,69 and I want to convert the display to:
3.225,69

Simply, I need full stop to separate thousand and comma to separate decimals:
3,69 -> 3,69 
1000 -> 1.000 
1500,20 -> 1.500,20
1 -> 1 (not 1,000)

Which mask should I use in to_char?
I'm my DB columns the comma means decimals.

A:

You can use the FM format modifier to have trailing decimal zeros blanked out:
select to_char(1, 'FM9G999G999D999', 'NLS_NUMERIC_CHARACTERS='',.''') from dual;

TO_CHAR(1,'FM9G999G999D999','NLS_NUMERIC_CHARACTERS='',.''')
------------------------------------------------------------
1,      

But as you can see that leaves the decimal character behind; you can trim that off though:
with t as (
 select 3.69 as n from dual
 union all select 1000 from dual
 union all select 150.20 from dual
 union all select 1 from dual
 union all select 0.16 from dual
)
select n,
  to_char(n, '9G999G999D000') original,
  to_char(n, 'FM9G999G999D999', 'NLS_NUMERIC_CHARACTERS='',.''') new,
  rtrim(to_char(n, 'FM9G999G999D999', 'NLS_NUMERIC_CHARACTERS='',.'''),
    ',') as trimmed
from t;

         N ORIGINAL       NEW            TRIMMED       
---------- -------------- -------------- --------------
      3.69          3.690 3,69           3,69           
      1000      1,000.000 1.000,         1.000          
     150.2        150.200 150,2          150,2          
         1          1.000 1,             1            
       .16           .160 ,16            ,16            

I'm using the optional third NLS argument to the to_char() function to set the G and D characters independently from my session settings.
If you want to preserve the zero befor the decimal separator, just make the last 9 before the D into a 0:
with t as (
 select 3.69 as n from dual
 union all select 1000 from dual
 union all select 150.20 from dual
 union all select 1 from dual
 union all select 0.16 from dual
)
select n,
  to_char(n, '9G99G990D000') original,
  to_char(n, 'FM9G999G990D999', 'NLS_NUMERIC_CHARACTERS='',.''') new,
  rtrim(to_char(n, 'FM9G999G990D999', 'NLS_NUMERIC_CHARACTERS='',.'''),
    ',') as trimmed
from t;

         N ORIGINAL      NEW            TRIMMED       
---------- ------------- -------------- --------------
      3.69         3.690 3,69           3,69           
      1000     1,000.000 1.000,         1.000          
     150.2       150.200 150,2          150,2          
         1         1.000 1,             1              
       .16         0.160 0,16           0,16           

