DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: formating select output

  1. #1
    Join Date
    Feb 2000
    Posts
    175

    Question

    Hi,

    I'm trying to output the contents of a table to a spool file. However, my select statement contains the 'to_char' operator that calculates and formats a field this seems to be altering my output to include an extra space eg

    select name||age||height from person;

    gives an output of

    billy30150 ----where name=billy age=30 height=150
    brian22139

    but if I change the sql to

    select name||to_char(age+15,'99')||height from person;

    gives an output of

    billy 40150
    brian 32139

    How do I ensure the 'new' space between name and calculated age does not appear??

    I've tried to keep the example simple....I hope it makes sense!!

    Any suggestions most welcome....

    Thanks in advance

    Moff.

  2. #2
    Join Date
    Sep 2000
    Posts
    26
    Try using LTRIM(TO_CHAR(age+15,'99')).

    Hope this helps

    Matt

  3. #3
    Join Date
    May 2001
    Posts
    55
    Use the LTRIM function

    select col1 || LTRIM(TO_CHAR(col2+15,'99')) || col3
    from TEST_SAN
    A farmer learns more from a bad harvest than a good one

  4. #4
    Join Date
    Feb 2000
    Posts
    175
    Works a treat....

    Thanks for your help

    Moff.

Posting Permissions

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


Click Here to Expand Forum to Full Width