Home » SQL & PL/SQL » SQL & PL/SQL » how to implement thousand separator from sql
how to implement thousand separator from sql [message #33247] Tue, 28 September 2004 23:45 Go to next message
krs
Messages: 9
Registered: November 2001
Junior Member
Hi,

I have a table TB1 with COL1 as column.

tb1.col1

---------

1234567.567

3456878.345

458937939

Now i want to read the records with comma as thousand separator. How to write the sql.

eg: select to_char(col1,.......) from tb1.

col1

----

1,234,567.567

3,456,878.345

458,937,939

Any help is appreciated.
Re: how to implement thousand separator from sql [message #33248 is a reply to message #33247] Wed, 29 September 2004 03:12 Go to previous messageGo to next message
raviranjan
Messages: 41
Registered: April 2004
Member
it would help u.....

select to_char('3234566777','999,999,999,999.99')from dual
TO_CHAR('3234566777','999,999,

3,234,566,777.00
Re: how to implement thousand separator from sql [message #33252 is a reply to message #33247] Wed, 29 September 2004 05:00 Go to previous messageGo to next message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
A safer approach would be to use this table's generic group separator (G) and decimal character (D), since the use of commas and periods varies by NLS_TERRITORY setting:
----------------------------------------------------------------------
SQL> SELECT value
  2  FROM   v$nls_parameters
  3  WHERE  parameter = 'NLS_TERRITORY'
  4  /
 
VALUE
----------------------------------------------------------------
AMERICA
 
SQL> SELECT TO_CHAR(9876543201 / 100,'999G999G990D00') amt
  2  FROM   DUAL
  3  /
 
AMT
---------------
  98,765,432.01
 
SQL> ALTER SESSION SET NLS_TERRITORY='GERMANY'
  2  /
 
Session altered.
 
SQL> SELECT TO_CHAR(9876543201 / 100,'999G999G990D00') amt
  2  FROM   DUAL
  3  /
 
AMT
---------------
  98.765.432,01
 
SQL>
Re: how to implement thousand separator from sql [message #33258 is a reply to message #33247] Wed, 29 September 2004 09:44 Go to previous message
Madonna of the Wasps
Messages: 15
Registered: September 2004
Junior Member
If truely in SQL*Plus and not PL/SQL, you can give a format statement as such:

col col1 format 999,999,999,990.999

Then do your select.
Previous Topic: How to Retrieve the rows which have only numeric Values
Next Topic: Need help in the query
Goto Forum:
  


Current Time: Thu Dec 25 12:25:59 CST 2025