Results 1 to 3 of 3

Thread: Convert string

  1. #1
    Join Date
    Feb 2005
    Posts
    29

    Unanswered: Convert string

    Hi,

    There is a requirement, where the number, if greater than 1000, had to be displayed as "," separated.
    E.g 10000 should be displayed as 10,000.
    153523 as 153,523


    is there any sql function available ? If not any suggestions? Right now I am doing it in a PL/SQL block.

    Thanks,
    Ash

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    PL/SQL ... so it's about Oracle, right? You could try with something like this:
    Code:
    SELECT ename,
           DECODE (SIGN (sal - 1000),
                   -1, TO_CHAR (sal),
                       TO_CHAR (sal, '999,999,990')
                  ) sal
      FROM EMP;

  3. #3
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool

    Actually, you don't need the DECODE:
    Code:
    SELECT ename, TO_CHAR (sal, '999,999,990') sal
      FROM EMP;
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •